2014-10-02 7 views
0

Пожалуйста, помогите мне создать макет, как этот экран: enter image description hereДинамическая компоновка с imageViews

Изображение позиция должна быть как на экране. Все временные изображения масштабируют или изменяют размеры границ.

<?xml version="1.0" encoding="utf-8"?> 

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

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:weightSum="3"> 

     <view 
      class=".widget.AvatarView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/view6" 
      android:gravity="center" 
      android:layout_weight="1" 
      android:layout_gravity="center" /> 

     <LinearLayout 
      android:orientation="vertical" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="2"> 

      <view 
       class=".widget.AvatarView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/view" 
       android:gravity="center" /> 

      <view 
       class=".widget.AvatarView" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:id="@+id/view11" 
       android:gravity="center" /> 
     </LinearLayout> 
    </TableRow> 

    <TableRow 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:gravity="center"> 

     <view 
      class=".widget.AvatarView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/view5" 
      android:layout_weight="1" 
      android:gravity="center" /> 

     <view 
      class=".widget.AvatarView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/view8" 
      android:layout_weight="1" 
      android:gravity="center"> 

     </view> 

     <view 
      class=".widget.AvatarView" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:id="@+id/view10" 
      android:layout_weight="1" 
      android:gravity="center"> 

     </view> 

    </TableRow> 
</TableLayout> 

Но изображения не требуют масштабирования и изменения размера! Я получаю enter image description here Пожалуйста, помогите, спасибо!

+0

Try [ 'GridLayout'] (http://developer.android.com/reference/android/widget/GridLayout.html) может быть ? –

+0

Вместо 'TableLayout' используйте' LinearLayout' с дополнением, ориентацией и весом. –

+0

@HimanshuAgarwal Я не могу растягиваться с линейной компоновкой – smail2133

ответ

0

Проверить этот макет образец, и вы можете настроить это для собственного

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

    <ScrollView 
    android:id="@+id/scrollView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentTop="true" > 

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

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

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:src="@drawable/ic_launcher" /> 

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

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_launcher" /> 

       <ImageView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:src="@drawable/ic_launcher" /> 
      </LinearLayout> 
     </LinearLayout> 

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

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher" 
       android:layout_weight="1"/> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher" 
       android:layout_weight="1" /> 
      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/ic_launcher" 
       android:layout_weight="1"/> 
     </LinearLayout> 
    </LinearLayout> 
    </ScrollView> 
</RelativeLayout> 
+0

Мне нужно поведение, как приложение tinder на скриншоте сверху. – smail2133

+0

да с этого кода вы можете редактировать в соответствии с вашими потребностями, он дает результат, аналогичный приведенному выше макету image –

+0

I моя логика, некоторые изображения отсчета могут быть пустыми, другие изображения растягиваются, я не хочу этого! Как это сделать? – smail2133

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