답변

0

나는이 작업을하기 위해 잠시 고생했으며 RelativeLayout으로 어떻게해야하는지 발견했습니다. 아래의 코드 예제를 참조 layout_toRightOf, layout_toLeftOf의 사용에주의를 지불하고 layout_alignParentRight

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/eventDetailSectionHeight" 
    android:background="@color/grayout"> 

    <SomeFixedWidthView 
     android:id="@+id/leftFixedWidthView" 
     android:layout_width="100dp" 
     android:layout_height="match_parent"/> 

    <SomeVariableWidthView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_toRightOf="@id/leftFixedWidthView" 
     android:layout_toLeftOf="@+id/rightFixedWidthView"/> 

    <SomeFixedWidthView 
     android:id="@+id/rightFixedWidthView" 
     android:layout_width="100dp" 
     android:layout_height="match_parent" 
     android:layout_alignParentRight="true"/> 

</RelativeLayout> 
0

는 요구 사항에 따라 각 자녀에 대한 layout_weight를 설정하십시오. 원하는 결과에 대한 코드 아래

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:weightSum="1"> 


     <View 
      android:id="@+id/leftView" 
      android:layout_width="0dp" 
      android:layout_weight="0.4" 
      android:layout_height="match_parent" 
      android:background="#ff0000"/> 

     <View 
      android:id="@+id/middleView" 
      android:layout_width="0dp" 
      android:layout_weight="0.2" 
      android:layout_height="match_parent" 
      android:background="#33cc33"/> 

     <View 
      android:id="@+id/rightView" 
      android:layout_width="0dp" 
      android:layout_weight="0.4" 
      android:layout_height="match_parent" 
      android:background="#ff0000"/>/> 


</LinearLayout> 
0

사용

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <View 
     android:id="@+id/leftView" 
     android:layout_width="100dp" 
     android:layout_height="match_parent" 
     android:background="#ff0000"/> 

    <View 
     android:id="@+id/middleView" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="1" 
     android:background="#33cc33"/> 

    <View 
     android:id="@+id/rightView" 
     android:layout_width="100dp" 
     android:layout_height="match_parent" 
     android:background="#ff0000"/> 

</LinearLayout>