2015-02-07 2 views
0

내 문제를 정확하게 설명하는 단어를 찾을 수 없습니다. 나는이 문제에 대해 아무런 해결책도없이 몇 시간을 생각하고 있었다.android layout 경계 위와 아래에 50 %

여기 내 문제를 더 잘 이해할 수있는 이미지입니다.

problem

그래서 내 viewB는 viewA 이하입니다. 문제있는 부분은 viewA와 viewB 연결 선이 내 viewC를 절반으로 나눌 수 있도록 viewC를 xml에 배치하는 방법입니다.

이 문제는 쉽게 해결할 수 있습니까? 나는 내 XML 코드로도 가까이 갈 수 없다.

어떤 종류의 사용자 정의보기가 이미 구축 되었습니까? 나는 대답을 찾으려고했지만 운이 없었습니다.

이 문제를 해결하기위한 모든 제안이 도움이됩니다.

+0

만하니 xml을 사용하고 싶습니까? 프로그래밍 방식으로 세 번째보기를 추가 할 수 있다면 비교적 쉽습니다. 섹스 x와 y 좌표를 추가하기 전에 세 번째보기의 –

+0

원래 원래 계획은 xml을 사용하는 것이 었습니다. 이것은 listview에서 내 행이 될 것입니다. 처음부터 내 뷰를 빌드해야한다면 더 복잡합니다. viewC 높이를 측정 한 다음 프로그래밍 방식으로 위치를 지정해야합니다. 어쩌면 누군가가 이미 이런 걸 만들었 을까요? – oiramcro

+0

보기 C의 높이를 알고 계시거나 랩 콘텐츠를 사용하십니까? –

답변

1

그 조금 복잡 하나 그러나 그것은 당신에게

이 질문

를 해결하는 데 도움이 될 것입니다 희망 원하는 결과를 줄 것이다

enter image description here

XML 코드 :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".MainActivity"> 
<LinearLayout 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 
    <TextView android:text="View A" android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#ff00ffe8" 
     android:id="@+id/a" 
     android:gravity="center" 
     android:layout_weight=".3" 
     android:textColor="#000" 
     /> 
    <TextView android:text="View B" android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#ffffe83b" 
     android:id="@+id/b" 
     android:layout_below="@+id/a" 
     android:gravity="center" 
     android:layout_weight=".7" 
     android:textColor="#000" 
     /> 
</LinearLayout> 
    <LinearLayout 
     android:weightSum="10" 
     android:orientation="vertical" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
     <LinearLayout android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#0000ffe8" 
      android:id="@+id/a1" 
      android:gravity="center" 
      android:layout_weight="3.5" 
      android:orientation="vertical" 
      android:textColor="#0000" 
      /> 

     <LinearLayout android:text="View B" android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#00ffe83b" 
      android:id="@+id/b1" 
      android:layout_below="@+id/a" 
      android:gravity="center" 
      android:layout_weight="6.5" 
      android:orientation="vertical" 
      android:textColor="#0000" 
      android:weightSum="3.5" 
      > 
      <TextView android:text="View C" android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="#ffff5b25" 
       android:id="@+id/b2" 
       android:layout_below="@+id/a" 
       android:gravity="center" 
       android:layout_weight="2.5" 
       android:layout_marginLeft="20dp" 
       android:layout_marginRight="30dp" 
       android:textColor="#000" 
       /> 
      <LinearLayout android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:background="#0000ffe8" 
       android:id="@+id/a2" 
       android:gravity="center" 
       android:layout_weight="1" 
       android:orientation="vertical" 
       android:textColor="#0000" 
       /> 
      </LinearLayout> 
    </LinearLayout> 

</RelativeLayout> 
+0

이 높이를 wrap_content로 설정하면 작동합니까? 전체 화면보기가 필요 없기 때문에 – oiramcro

+0

루트 레이아웃 높이를 변경하거나 특정 높이를 설정할 수 있습니다. –