2014-11-05 2 views
0

Я хочу создать этот макет, где есть три равных ImageViews в линейном макете с layout_weight = 1.0 каждый. Я просто хочу поместить два круговых изображения на внутренние края, выровненные по центру вертикально в android. Может быть, я не могу добиться этого в XML или, может быть, да. Пожалуйста, помогите мне достичь этого enter image description here должным образом.Как я могу достичь этого макета в Android?

+0

, что вы пытаетесь до? –

+1

используйте 'FrameLayout', чтобы содержать эти равномерно распределенные ImageViews и добавлять к нему кнопку, придавая ей« серьезность »« центра »и некоторую« marginLeft ». –

ответ

1

Попробуйте этот путь, надейтесь, что это поможет вам решить вашу проблему.

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/white"> 

     </LinearLayout> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/black"> 

     </LinearLayout> 
     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="@android:color/white"> 

     </LinearLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:gravity="center"> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      android:gravity="right"> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher"/> 
     </LinearLayout> 

     <View 
      android:layout_width="0dp" 
      android:layout_height="1dp" 
      android:layout_weight="1"/> 

     <LinearLayout 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="2" 
      android:gravity="left"> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher"/> 
     </LinearLayout> 
    </LinearLayout> 
</FrameLayout> 
+1

. Все хорошие люди благодаря тому, что это сработало как шарм. –

+0

@ Dr.aNdRO, рад помочь вам, дорогой ... –

+0

Но это не идеально подходит для всех устройств –

1
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical" > 

<FrameLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="horizontal" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="#123456" 
      android:orientation="vertical" > 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:background="#654321" 
      android:orientation="vertical" > 
     </LinearLayout> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_weight="1" 
      android:orientation="vertical" > 
     </LinearLayout> 
    </LinearLayout> 

    <FrameLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" > 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:gravity="center" 
      android:orientation="vertical" > 

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

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:gravity="right" 
        android:orientation="vertical" > 

        <ImageView 
         android:id="@+id/imageView1" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginRight="30dp" 
         android:src="@android:drawable/alert_dark_frame" /> 

       </LinearLayout> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_weight="1" 
        android:orientation="vertical" > 

        <ImageView 
         android:id="@+id/imageView2" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:layout_marginLeft="30dp" 
         android:src="@android:drawable/alert_light_frame" /> 

       </LinearLayout> 
      </LinearLayout> 
     </LinearLayout> 
    </FrameLayout> 
</FrameLayout> 

</LinearLayout> 

Look This

+0

Все хорошие люди благодаря работе, –

Смежные вопросы