2016-08-11 3 views
0

다음과 같은 문제가 있습니다.이 경우 두 개의 파트, 상단 탐색 모음, 더 딱딱한 동작 또는 도구 모음을이 경우 더 복잡한 이유로 탐색 모음을 설정하는 옵션으로 분할하고 싶습니다. 다른 기기 (전화/패드)의 절대 값과 백분율 값이 다르므로 %가 너무 어렵습니다.분할 화면 비율 및 dp

내비게이션 막대 부분은 100dp 여야하고 RelativeLayout의 새로운 100 % 화면을 사용하려면 fill_parent을 사용하면 흰색 부분이 100과 같을 것입니다. %.

가능한 경우 axml 솔루션이 우선적으로 적용되므로 C# 또는 Java 기반의 모든 것이 옵션이지만 잘못된 것입니다.

Example

나는 다음을 수행 다만하려고하지만 난 그냥 corretly, 내가이 문제를 해결하는 방법을 알아낼 질수 전체 상위 개체의 크기를 설정 생각합니다.

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#f0f0f0" > 

<LinearLayout android:layout_width="fill_parent" 
      android:layout_height="100dp" 
      android:background="#ffffff">  
<!--Some Content--> 
</LinearLayout> 
<RelativeLayout 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">  
    <android.support.percent.PercentRelativeLayout 
     android:layout_width="0dip" 
     android:layout_height="fill_parent" 
     app:layout_widthPercent="100%" 
     app:layout_heightPercent="100%" 
     android:background="#ffffff"> 
    <!--Some Content--> 
</RelativeLayout> 
</RelativeLayout> 
+1

'android : layout_weight' 사용을 시도하십시오. – Berkay92

+0

특히 얼마나 좋습니까? 내가 정확히 기억한다면 그것은 두 부분 모두에 백분율에 기초한 가중치를 부여 할 것이지만, 그 지역의 한 부분 만 백분율을 기준으로 할 수 있습니다. 예를 들어 주시겠습니까? –

답변

1

귀하의 혼란은 PercentRelativeLayout 자체에 백분율 값을 사용하는 결과입니다 만 그 아이에 사람들을 사용할 수 있습니다. 다음 예제에서는 100dp 도구 모음과 모든 빈 공간을 사용하는 동안 RelativeLayout이 바로 아래에 배치되어 있습니다. 이 레이아웃의 모든 하위 항목은 전체 화면이 아닌 PercentRelativeLayout에 상대적으로 측정됩니다.

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#f0f0f0" > 

    <LinearLayout 
       android:id="@+id/toolBarLayout" 
       android:layout_width="match_parent" 
       android:layout_height="100dp" 
       android:background="#ffffff">  
    <!--Some Content--> 
    </LinearLayout> 

    <android.support.percent.PercentRelativeLayout 
      android:layout_below="@id/toolBarLayout" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:background="#ffffff"> 

      <!-- all the content here may be measured relatively to 
      a parent PercentRelativeLayout --> 

      <ImageView 
        android:layout_width="match_parent" 
        app:layout_heightPercent="50%"/> 

    </android.support.percent.PercentRelativeLayout> 

</RelativeLayout> 
+0

임 회의 중 임, 나는 이것을 시험해 볼 시간이있을 때 내일 의견을 줄 것이다. –

0

아래와 같이 화면을 나눌 수 있습니다.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="#ffffff" 
    android:orientation="vertical" 
    android:id="@+id/layoutfifth"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center" 
     android:orientation="horizontal"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" 
      android:orientation="vertical"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="Text 1" 
       android:textColor="#000000" 
       android:textSize="13sp" 
       android:textStyle="bold" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="Text 2" 
       android:textColor="#000000" 
       android:textSize="13sp" 
       android:textStyle="bold" /> 


     </LinearLayout> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_margin="5dp" 
      android:layout_weight="1" 
      android:orientation="vertical"> 



      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="Text 3" 
       android:textColor="#000000" 
       android:textSize="13sp" 
       android:textStyle="bold" /> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginTop="10dp" 
       android:text="Text 4" 
       android:textColor="#000000" 
       android:textSize="13sp" 
       android:textStyle="bold" /> 



     </LinearLayout> 


    </LinearLayout> 

</LinearLayout>