2016-08-19 3 views
3

Ich habe ein Problem, wie ich auf dem Titel erwähnt, wenn ich versuche, eine Tabellenansicht zu erstellen, die durch Verwendung von horizontal scrollen kann android.support.v17.leanback.widget.HorizontalGridViewSet Spaltenanzahl und horizontal in HorizontalGridView Android

Ergebnis sieht wie folgt aus: enter image description here

Aber ich brauche etwas Raum zwischen jedem Elemente und Steuerbetrag von Artikel auf dem Bildschirm wie folgt angezeigt: enter image description here

Mein layout.xml Code:

<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" 
/> 

Ich habe versuchen, Code unten zu verwenden, aber es ist zu sehen, um nicht-Effekt auf allen

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

Es ist der Code von 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> 

Thank Sie so viel

Antwort

0

Ich bin gerade auf dieses Datum gestoßen und aus irgendeinem Grund zeigt Android Studio (2.3 zum Zeitpunkt des Schreibens) nicht alle Autokomplettierungsoptionen für HorizontalGridView (Leanback v17).

Was Sie anstreben ist:

android:horizontalSpacing="10dp"

oder Sie können es tun programmatisch über

gridView.setHorizontalSpacing(10)

, wobei 10 der Abstand in Pixel.