2017-04-02 13 views
0

固定幅のカードを維持するためのアプリを作成しています。それで、デバイスの幅に応じて動的にカードビューを埋め込む方法。デバイスの幅に応じて動的にカードビューを埋め込む方法

例:通常のサイズの携帯電話の場合は、2列のカードが必要で、大きなサイズの画面の場合は、両方の携帯電話でポートレートモードに設定されている場合は3列のカードがあります。このよう

: ソリューション、GridViewコントロールを使用する

必要性を手に入れた3 column cards example 2 column cards example

答えて

0

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="app.appmax.fest1.Dialogs.CustomGridView.MenuHome"> 

    <GridView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:columnWidth="100dp" 
     android:layout_marginLeft="8dp" 
     android:layout_marginTop="8dp" 
     android:stretchMode="columnWidth" 
     android:id="@+id/gridview1" 
     android:numColumns="auto_fit" 
     > 


    </GridView> 


</RelativeLayout> 
関連する問題