2017-02-25 6 views
1

동일한 레이아웃을 여러 가지 형식으로 사용하고 싶습니다. 따라서 크기를 변경해야합니다.appwidget에서 레이아웃 객체의 너비를 변경하는 방법은 무엇입니까?

idpicframe을 사용하여 RelativeLayout의 너비를 프로그래밍 방식으로 어떻게 변경할 수 있습니까?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/item_frame" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:paddingLeft="3dp" 
     android:paddingRight="3dp" 
     android:gravity="left" 
     android:layout_centerVertical="true"> 

    <RelativeLayout 
      android:id="@+id/picframe" 
      android:layout_width="35dp" 
      android:layout_height="35dp" 
      android:layout_gravity="center" 
      android:layout_marginLeft="5dp" 
      android:layout_marginRight="10dp" > 

     <ImageView 
       android:id="@+id/picture" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:scaleType="fitCenter" 
       android:layout_centerInParent="true" 
       android:adjustViewBounds="true" 
       android:contentDescription="@string/app_name" /> 

     <ImageView 
       android:id="@+id/overlay" 
       android:layout_width="fill_parent" 
       android:layout_height="fill_parent" 
       android:scaleType="fitCenter" 
       android:layout_centerInParent="true" 
       android:adjustViewBounds="true" 
       android:contentDescription="@string/app_name" /> 
... 

내가 성공하지

remoteView.setString(R.id.picframe, "setWidth", "50dp"); 

remoteView.setString(R.id.picframe, "setLayoutWidth", "50dp"); 

을 시도했습니다.

답변

0

나는 시도하지 않을 것이다. 최상위 레벨보기를 상대 레이아웃 대신 <merge>으로 만들고 너비가 원하는 레이아웃으로 병합합니다.

+0

'병합'태그에 대한 힌트를 주셔서 감사합니다. 그러나이 경우에는 레이아웃이이 스 니펫에서 볼 수있는 것보다 더 복잡하기 때문에 필요합니다. – Wookiee