2015-07-22 2 views
0

Что является лучшим способом для достижения дизайнерской иконки с текстом с библиотекой поддержки для дизайна material.It будет выглядеть, как изображение выше ссылка enter link description hereGridLayout стиль дизайна с иконками и текстом с использованием материального дизайна?

+1

Вложенный 'LinearLayout' – Karakuri

ответ

1

Как Karakuri сказал в комментариях, вложенное LinearLayouts будет сделать ваш требуемый вид, как этот

enter image description here

Вот код для размещения

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:weightSum="3" 
    android:padding="16dp" 
    android:orientation="horizontal"> 


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

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

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Repeat"/> 

    </LinearLayout> 

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

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

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Favourite"/> 

    </LinearLayout> 

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

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

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Shuffle"/> 

    </LinearLayout> 

</LinearLayout> 

Код - это всего лишь структура макета, вам нужно добавить paddings и ImageView ширину ширины, как вы хотите. Вы должны сделать небольшую работу для желаемого макета. Если вы хотите, чтобы две строки совпадали с загруженным изображением, просто дважды скопируйте макет.

Надеюсь, что это поможет или оставьте комментарий, если возникнут проблемы.

Cheers!

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