2015-05-28 78 views
0

我要创建的布局,有一个形象,多的TextView和评价这样的,我有添加与适配器充气这种布局线线性布局与图像和文本

| Image| Name of Product   | 
|  Desc      | 
|  Amount      | 
|  EMI details     | 
|  Rating Sybmol total Rating | 

所以我试图创建布局像这样

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" > 
    <LinearLayout 
     android:id="@+id/mainLinearLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:orientation="horizontal" > 
     <ImageView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:src="@mipmap/ic_launcher" 
      android:layout_marginTop="5dp" 
      android:layout_marginLeft="10dp"/> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="10dp" 
      android:layout_marginLeft="10dp" 
      android:id="@+id/text" 
      android:text="Micromax Canvas Spark" 
      android:textColor="@android:color/black" /> 
    </LinearLayout> 
</RelativeLayout> 

但我很困惑,我怎么可以创建布局,请帮我在这

+1

你想他形象,他离开和textViews向右? –

+0

@EugeneH是,列表视图中的每一行是行,当我在列表视图中打印时 – Developer

+0

我不太清楚你的意思。 –

回答

5

这就是我假设你正在试图完成的任务。

enter image description here

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal"> 

    <ImageView 
     android:layout_width="48dp" 
     android:layout_height="48dp" 
     android:layout_marginLeft="16dp" 
     android:layout_marginTop="16dp" 
     android:src="@mipmap/ic_launcher"/> 

    <LinearLayout 
     android:id="@+id/mainLinearLayout" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_marginLeft="72dp" 
     android:orientation="vertical"> 


     <TextView 
      android:id="@+id/text" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="16dp" 
      android:text="Micromax Canvas Spark" 
      android:textColor="@android:color/black"/> 

     <TextView 
      android:id="@+id/text1" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="10dp" 
      android:text="Micromax Canvas Spark" 
      android:textColor="@android:color/black"/> 

     <TextView 
      android:id="@+id/text2" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="10dp" 
      android:text="Micromax Canvas Spark" 
      android:textColor="@android:color/black"/> 

     <TextView 
      android:id="@+id/text3" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="10dp" 
      android:text="Micromax Canvas Spark" 
      android:textColor="@android:color/black"/> 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:orientation="horizontal" 
      android:layout_marginLeft="10dp" 
      android:layout_marginTop="10dp"> 

      <RatingBar 
       android:id="@+id/ratingBar" 
       style="?android:attr/ratingBarStyleSmall" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_vertical" 
       android:rating="2"/> 

      <TextView 
       android:id="@+id/text4" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="16dp" 
       android:text="1003 Votes" 
       android:textColor="@android:color/black"/> 

     </LinearLayout> 
    </LinearLayout> 
</RelativeLayout> 

分频器的ListView控件

<ListView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:divider="#fff" 
    android:dividerHeight="1dp"/> 

更新

更改等级栏的大小。

style="?android:attr/ratingBarStyleSmall" 
style="?android:attr/ratingBarStyleIndicator" // Perfect Size but stars are blue 
+0

我们如何才能在此布局中显示评级星或评级符号 – Developer

+0

恰恰是我正在尝试,但我还需要向此评级符号显示 – Developer

+0

使用评级栏更新布局 –

0
I have implemented based on your prototype. 

<?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="wrap_content" > 

    <ImageView 
     android:id="@+id/imageView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentStart="true" 
     android:src="@drawable/ic_launcher" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_toRightOf="@+id/imageView1" 
     android:orientation="vertical" > 

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

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Name of Product:" /> 

      <TextView 
       android:id="@+id/txt_name_of_Product" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="---" /> 
     </LinearLayout> 

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

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="Desc:" /> 

      <TextView 
       android:id="@+id/txt_desc" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="---" /> 
     </LinearLayout> 

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

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="AMT:" /> 

      <TextView 
       android:id="@+id/txt_amount" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="---" /> 
     </LinearLayout> 

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

      <TextView 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="EMI Details:" /> 

      <TextView 
       android:id="@+id/txt_emi_detais" 
       android:layout_width="0dp" 
       android:layout_height="wrap_content" 
       android:layout_weight="1" 
       android:text="---" /> 
     </LinearLayout> 

     <RatingBar 
      android:id="@+id/ratingBar1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:scaleX="0.5" 
      android:scaleY="0.5" /> 
    </LinearLayout> 

</RelativeLayout> 
+0

,但我们需要在评分栏后添加总评分数? – Developer

+0

然后,您可以在评分栏中添加android:numStars =“8”属性。 – user2477865

+0

不,我必须显示文本视图,并在评级栏后显示评分的一些详细信息 – Developer