2015-05-28 4 views
0

я должен создать макет, которые имеют одно изображение и несколько TextView и рейтинг, как это и я должен добавить строку на надувать этот макет с адаптеромLinear Layout с изображением и текстом

| 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 yes и строка для каждой строки в представлении списка, когда я делаю это в виде списка – 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"/> 

Update

Изменение размера рейтинга бара.

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

no Мне нужно показать текстовое представление с некоторыми деталями для рейтингов после бара оценки – Developer

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