2013-07-18 2 views
0

다음과 같은 내용을 만들려고합니다.상대 레이아웃의 크기를 동적으로 조정하십시오.

나는 헤더를 작동시키는 것으로 정렬 할 수 있으며 오른쪽에 단어 구름 모양이 비슷합니다. 조각에서 가져옵니다.

하지만 두 열의 작업을 수행하는 데 어려움을 겪고 있습니다. parentLayout이 layout_width = "match_parent"나는 자습서를 찾을 수 없습니다

/예있는 동안,

parentLayout = (RelativeLayout) view.findViewById(R.id.ParentLayout); 
parentLayout.getMeasuredWidth() 

이 0을 반환

는이 같은 부모의 폭을 얻기 위해 노력 이 유형의 '보기'또는 검색에 사용하는 키워드가 잘못되었을 수 있습니다.

모든 의견을 환영합니다! 미리 감사드립니다 !!

p.s. 나뿐만 아니라 된 onMeasure()를 사용하려고했으나 잘 레이아웃의 유형을 처리 할 수있는 정말

Page

답변

0

선형 레이아웃을 "무시하거나 슈퍼 방법을 구현해야합니다"오류가 발생했습니다. 나는 이런 배열을 사용한다 :

<?xml version="1.0" encoding="utf-8"?> 

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_height="fill_parent" 
     android:background="@color/black" 
     android:orientation="vertical" 
     android:layout_width="fill_parent"> 
     <!-- your header stuff here 

     --> 
     <LinearLayout android:layout_height="wrap_content" 
        android:layout_width="wrap_content" 
        android:orientation="horizontal" 
        > 

      <LinearLayout android:id="left picture pane" 
        android:orientation="vertical" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
      > 
       <ImageView android:layout_width="100dp" 
          android:background="@drawable/logo" 
          android:layout_height="50dp" 
          android:layout_margin="10dp" 
          /> 
       <ImageView android:layout_width="100dp" 
          android:background="@drawable/logo" 
          android:layout_height="50dp" 
          android:layout_margin="10dp" 
         /> 
       <ImageView android:layout_width="100dp" 
          android:background="@drawable/logo" 
          android:layout_height="50dp" 
          android:layout_margin="10dp" 
         /> 

      </LinearLayout> 
      <LinearLayout 
       android:orientation="vertical" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" > 
        <TextView android:layout_width="wrap_content" 
           android:layout_height="wrap_content" 
           android:text="Some Text" 
           android:textColor="#FFFFFF" 
           android:layout_marginTop="20dp" 
           android:layout_marginLeft="10dp" 
           /> 
       <TextView android:layout_width="wrap_content" 
          android:layout_height="wrap_content" 
          android:text="Some Text" 
          android:textColor="#80ffff" 
          android:layout_marginTop="2dp" 
          android:layout_marginLeft="15dp" 
         /> 
           <!-- your fancy lettering in here 
            or you could put them in a relative layout 
            instead of this linear one --> 
      </LinearLayout> 
     </LinearLayout> 
</LinearLayout> 
+0

안녕하세요, 고마워, 잘 작동합니다. 그러나 내 주요 관심사는 실제로 화면 크기 또는 방향에 따라 서로에 대해 동적으로 모든 크기를 조정할 수 있습니다 (미안하지만 그 질문에 명확하게하지 않았 음). 어떤 제안? 감사!! – Merelda

+0

어쨌든 올바른 방향으로 나를 가리켜 주셔서 감사합니다! – Merelda

관련 문제