2016-08-11 4 views
0

次の問題がありました.2つのパーツ、トップナビゲーションバー、よりぬくもりのアクション、ツールバーを分​​割する場合は、この場合複雑な理由でナビゲーションバーを設定するオプションですパーセンテージの値が異なるデバイス(Phone/Pad)の絶対サイズと異なるため、%もかなり難しいです。スプリットスクリーンパーセンテージと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つのパーツだけがパーセンテージに基づいている可能性があります。例を教えていただけますか? –

答えて

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> 
関連する問題