2017-02-09 7 views
0

Ich schlug in Layout-Gewicht-Konzept, die einen Text unten zu jeder Bildansicht platzieren müssen und ich versuchte viele Methoden in Gewicht-Konzept, aber textView geht irgendwo.Ich befestigte meine Xml hier und wenn jemand Vorschläge haben, geben Sie mir eine Idee, dies zu lösen Danke im VorausWie platziere ich eine Textansicht unten zu jedem Imageview?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:id="@+id/topBar" 
      style="@style/IconBar" 
      android:layout_width="match_parent" 
      android:layout_height="90dp" 
      android:baselineAligned="true" 
      android:orientation="horizontal" 
      android:weightSum="4" > 


<ImageButton 
    android:id="@+id/home" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_weight="0.8" 
    android:background="@android:color/transparent" 
    android:src="@drawable/glow" 
    android:visibility="gone"/> 

<RelativeLayout 
    android:id="@+id/relative" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <ImageView 
     android:id="@+id/imageLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:layout_weight="0.8" 
     android:src="@drawable/glow"/> 

    <TextView 
     android:id="@+id/textLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/imageLabel" 
     android:layout_centerInParent="true" 
     android:singleLine="true" 
     android:text="Israel News" 
     android:textSize="18sp" 
     android:textStyle="bold"/> 
</RelativeLayout> 

<ImageButton 
    android:id="@+id/email" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_weight="0.8" 
    android:background="@android:color/transparent" 
    android:src="@drawable/glow" /> 

<ImageButton 
    android:id="@+id/place" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_weight="0.8" 
    android:background="@android:color/transparent" 
    android:src="@drawable/glow" /> 

<ImageButton 
    android:id="@+id/account" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_weight="0.8" 
    android:background="@android:color/transparent" 
    android:src="@drawable/glow" /> 
<ImageButton 
    android:id="@+id/accounts" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_weight="0.8" 
    android:background="@android:color/transparent" 
    android:src="@drawable/glow" /> 

</LinearLayout> 
+1

Wo die Textviews sind? – akash93

+0

@ akash93Aktualisiert meinen Code – HsRaja

+0

Das 'Layout_weight' muss einem direkten Kind des' LinearLayout' in diesem Fall dem 'RelativeLayout' zugewiesen werden. – akash93

Antwort

0

Um Textview unter jedem Image anzuwenden, müssen Sie ein Layout als Elternteil für jedes Textview und Image als Kind

<LinearLayout 
     android:id="@+id/parent_home" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:orientation="vertical" 
     android:weightSum="1"> 

     <ImageButton 
      android:layout_weight="0.8" 
      android:id="@+id/home" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@android:color/transparent" 
      android:src="@drawable/glow" /> 

     <TextView 
      android:layout_weight="0.2" 
      android:id="@+id/homeText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@android:color/transparent" 
      android:text="Email Text"/> 

    </LinearLayout> 
+0

Es wurde nicht gleichmäßig nach Gewicht aufgeteilt und ich möchte auch den Text unten auf imageview behalten mit etwas paddingtop – HsRaja

Verwandte Themen