2013-10-16 20 views
0

我試圖在徽章末尾的textview中添加徽章,但是當我在我的設備上運行樣本時,bagde被包裝爲textview大小。我想要它的右下方的textview長度。徽章圖標定位在TextView長度的右下方Android

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app1="http://schemas.android.com/apk/res/socialbible.reef" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     android:clickable="false" 
     android:focusable="false" 
     android:paddingLeft="@dimen/ten_dp" > 

     <TextView 
      android:id="@+id/txNumber" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginRight="@dimen/one_dp" 
      android:clickable="false" 
      android:focusable="false" 
      android:text="60" 
      android:textColor="@color/black" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/myButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="false" 
      android:layout_toRightOf="@+id/txNumber" 
      android:background="@color/transparent" 
      android:clickable="false" 
      android:focusable="false" 
      android:gravity="top" 
      android:paddingBottom="@dimen/six_dp" 
      android:text="1111111111111111" /> 

     <TextView 
      android:id="@+id/txCommentaires" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/myButton" 
      android:layout_alignParentBottom="false" 
      android:layout_alignRight="@+id/myButton" 
      android:layout_marginLeft="@dimen/ten_dp" 
      android:background="@drawable/badge_circle" 
      android:clickable="false" 
      android:focusable="false" 
      android:paddingLeft="@dimen/six_dp" 
      android:paddingRight="@dimen/six_dp" 
      android:text="10" 
      android:textColor="#FFF" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 

    </RelativeLayout> 

enter image description here

回答

0

試試這個

<TextView 
    android:id="@+id/txCommentaires" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/myButton" 
    android:layout_toRightOf="@+id/myButton" 
    android:clickable="false" 
    android:focusable="false" 
    android:background="@drawable/badge_circle" 
    android:text="10" 
    android:textColor="#FFF" 
    android:textSize="16sp" 
    android:textStyle="bold" /> 
+0

爲兩個或多行txCommentaires變得不可見。 – Dimitri

+0

你可以發佈你所得到的圖像 – Manishika

+0

好的檢查我的問題。 – Dimitri

0

我試着和它的工作。

enter image description here

<?xml version="1.0" encoding="utf-8"?> 

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app1="http://schemas.android.com/apk/res/socialbible.reef" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:background="#FFFFFF" 
     android:clickable="false" 
     android:focusable="false" 
     android:paddingLeft="10dp" > 

     <TextView 
      android:id="@+id/txNumber" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_marginRight="1dp" 
      android:clickable="false" 
      android:focusable="false" 
      android:text="60" 
      android:textColor="#000000" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 

     <TextView 
      android:id="@+id/myButton" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="false" 
      android:layout_toRightOf="@+id/txNumber" 

      android:clickable="false" 
      android:focusable="false" 
      android:gravity="top" 
      android:paddingBottom="6dp" 
      android:text="1111111111111111gggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhh" /> 

     <TextView 
      android:id="@+id/txCommentaires" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignBottom="@+id/myButton" 
      android:layout_alignParentBottom="false" 
      android:layout_alignRight="@+id/myButton" 
      android:layout_marginLeft="10dp" 
      android:clickable="false" 
      android:focusable="false" 
      android:paddingLeft="6dp" 
      android:paddingRight="6dp" 
      android:text="10" 
      android:textColor="#333333" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 

    </RelativeLayout> 
+0

是的,但我想要在hhhhhhh結束時的徽章圖標 – Dimitri