3

こんにちは私はAndroid携帯とタブレットの両方のために私のアプリを設計しようとしています。だから私はすでにそれを設計しましたが、異なる画面のスケーリングの目的で再設計する必要がありました。

ここに画像の説明を入力してください

これが目的のレイアウトです。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:background="@color/white">
  
    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="2"
        android:orientation="horizontal" >
    
    <fragment
        android:id="@+id/map"
        android:layout_marginTop="5dp"
        android:layout_weight=".1"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        class="com.google.android.gms.maps.MapFragment"
         />
  
    <Button
        android:id="@+id/button3"
        android:layout_weight=".25"
        android:layout_marginLeft="34dp"
        android:layout_marginTop="10dp"
           android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:onClick="ClickTourismButton"
        android:text="@string/Tourism" />
    
    <Button
        android:id="@+id/button4"
        android:layout_weight=".25"
           android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginLeft="34dp"
        android:text="@string/Nearby" />
    <Button
        android:id="@+id/button2"
        android:layout_weight=".25"
        android:layout_marginLeft="34dp"
           android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:text="@string/Favourites" />
    <Button
        android:id="@+id/button1"
        android:layout_weight=".25"
          android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginLeft="34dp"  
        android:text="@string/Map" />
         
    </LinearLayout>   
    
    
    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:weightSum="2"
        android:orientation="horizontal" >
    <TextView
       
        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:textIsSelectable="true"      
        android:id="@+id/feedupdate1" />
    
    <ListView
        android:id="@android:id/list"
        android:background="@color/red"
        android:layout_weight="1"       
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"/>
    
    <TextView
        android:id="@+id/empty"
        android:textIsSelectable="true"   
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"  
        android:layout_marginLeft="10dp"
         android:layout_marginTop="5dp"/>
    <TextView
        android:id="@+id/feedupdate"        
        android:layout_marginLeft="6dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginTop="430dp"
        android:textIsSelectable="true"/>
    <ListView
         
        android:id="@+id/list1"
        android:background="@color/blue"
        android:layout_weight="1"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginTop="430dp"
        android:layout_marginLeft="6dp" /> 
    
    </LinearLayout>
</RelativeLayout>

アプリを実行すると、2つの線形レイアウトが重なり合っていますか?または、黒い長方形がすべての画面を占めるように上に表示されているマップフラグメント??? 私は何が間違っているのか分かりません、私はいくつかのチュートリアルを調べました、そしてtは正しいように見えますか?

助けが必要です

ありがとう


<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/LinearLayout"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="horizontal"
    android:weightSum="2"
    android:background="@color/white">

    <LinearLayout
        android:id="@+id/linearLayout1"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical" >

    <fragment
        android:id="@+id/map"
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        class="com.google.android.gms.maps.MapFragment"
         />

    <Button
        android:id="@+id/button3"
        android:layout_marginLeft="34dp"
        android:layout_marginTop="10dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:onClick="ClickTourismButton"
        android:text="@string/Tourism" />

    <Button
        android:id="@+id/button4"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginLeft="34dp"
        android:text="@string/Nearby" />
    <Button
        android:id="@+id/button2"
        android:layout_marginLeft="34dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:text="@string/Favourites" />
    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content" 
        android:layout_height="0dp"
        android:layout_marginLeft="34dp"  
        android:text="@string/Map" />

    </LinearLayout>   


    <LinearLayout
        android:id="@+id/linearLayout2"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_weight="1"
        android:orientation="vertical" >
    <TextView

        android:layout_marginLeft="10dp"
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:textIsSelectable="true"      
        android:id="@+id/feedupdate1" />

    <ListView
        android:id="@android:id/list"
        android:background="@color/red"    
        android:layout_marginTop="5dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"/>

    <TextView
        android:id="@+id/empty"
        android:textIsSelectable="true"   
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"  
        android:layout_marginLeft="10dp"
         android:layout_marginTop="5dp"/>
    <TextView
        android:id="@+id/feedupdate"        
        android:layout_marginLeft="6dp"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginTop="430dp"
        android:textIsSelectable="true"/>
    <ListView

        android:id="@+id/list1"
        android:background="@color/blue"
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content"
        android:layout_marginTop="430dp"
        android:layout_marginLeft="6dp" /> 

    </LinearLayout>
</LinearLayout>

ここに画像の説明を入力してください

1つのコンポーネントがそれぞれの側を占めますか?それは2つに分割されていますが、マップフラグメントは一方の側すべてを占め、最初のリストビューはもう一方のすべてを占めます???

4

3 に答える 3

11
  1. 両方の子LinearLayoutsの方向を次のように変更しますVERTICAL

  2. 上部の場合、Relativeを削除し、LinearLayoutを方向付けHORIZONTAL して使用します。weightSum=2

  3. 現在、両方の子のlinearlayoutビューlayout_width="0dp" で、layout_weight="1"


XMLの例:http://pastebin.com/2MCBN9qk

于 2013-03-25T12:56:39.560 に答える
2

LinearLayoutでRelativeLayoutを変更してみてください。さまざまなタイプのレイアウトについてより深く理解するには、このリンクを参照してください。

于 2013-03-25T12:56:45.137 に答える
1

weightSumを使用して、相対レイアウト内に線形レイアウトを追加して、配置を改善してください。

于 2016-03-28T06:32:33.743 に答える