2016-08-19 8 views
3

私は、タイトルの上に述べたように、私はandroid.support.v17.leanback.widget.Horizo​​ntalGridViewセットの列数と水平

を使用することにより、水平方向にスクロールできるグリッドビューを作成しようとすると、私は問題を持っています

結果そのようになります。このように画面に表示され enter image description here

しかし、私はアイテムの各項目と制御量の間にいくつかのスペースを必要とする: enter image description here

マイlayout.xmlコード:

<LinearLayout 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="fill_parent" 
android:layout_height="fill_parent" 
android:layout_centerHorizontal="true" 
android:orientation="vertical" 
tools:context="layout.productListFragment"> 

<!-- TODO: Update blank fragment layout --> 

<android.support.v17.leanback.widget.HorizontalGridView  xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/productListGrid" 
android:layout_width="wrap_content" 
android:layout_height="fill_parent" 
android:gravity="top" 
/> 

私は以下のコードを使用しようとしているが、single_product_layout

<?xml version="1.0" encoding="utf-8"?> 
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#FFFFFF" 
android:paddingLeft="5dp" 
android:paddingRight="5dp"> 

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

    <ImageView 
     android:id="@+id/singleProduct_image" 
     android:layout_width="wrap_content" 
     android:layout_height="150dp" 
     android:layout_gravity="top" 
     android:layout_span="2" 
     android:src="@drawable/product1" /> 
</TableRow> 

<TableRow> 

    <TextView 
     android:id="@+id/singleProduct_name" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/singleProduct_image" 
     android:gravity="left" 
     android:text="Tên sản phẩm" 
     android:textSize="12dp" 
     android:textStyle="bold" /> 
</TableRow> 

<TableRow> 

    <RatingBar 
     android:id="@+id/singpleProduct_ratingBar" 
     style="?android:attr/ratingBarStyleSmall" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/singleProduct_name" 
     android:layout_gravity="left" 
     android:layout_weight="4" 
     android:numStars="5" /> 

    <TextView 
     android:id="@+id/singleProduct_price" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignEnd="@+id/singleProduct_image" 
     android:layout_below="@+id/singleProduct_name" 
     android:layout_gravity="right" 
     android:layout_weight="6" 
     android:gravity="right" 
     android:text="25.000VND" 
     android:textColor="@color/mainThemeColor" 
     android:textSize="10dp" /> 
</TableRow> 

</TableLayout> 

感謝のコードがあり、すべての

android: android:numColumns="3" 
android:columnWidth="60dp" 
android:stretchMode="columnWidth" 

で有効にならなかったために見ていますあなたはそんなに

答えて

0

私はちょうどこれを今日遭遇しました。何らかの理由でAndroid Studio(本書の執筆時点では2.3)にHorizontalGridView(Leanback v17)のオートコンプリートオプションがすべて表示されていません。

android:horizontalSpacing="10dp"

またはあなたが10ピクセル単位で間隔がある

gridView.setHorizontalSpacing(10)

を経由して、プログラムでそれを行うことができます。

何を目指していることです。

関連する問題