2016-09-28 5 views
0

TextViewlayout_toRightOfImageViewと置き換えたい場合はとします。なぜ私はTextViewが見えないのですか?これを解決する方法。layout_alignParentRight = "true"の表示のレイアウトをlayout_toRightOfで表示できない理由

私の問題コード!私はテキストの "77" を見ることができないのはなぜ

<RelativeLayout 
    android:orientation="horizontal" 
    android:minWidth="20px" 
    android:minHeight="20px" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:id="@+id/bottomBar"> 
    <ImageButton 
     android:src="@drawable/likes" 
     android:background="#ffffff" 
     android:layout_width="25dp" 
     android:layout_height="25dp" 
     android:layout_marginRight="8dp" 
     android:id="@+id/likeImage" 
     android:layout_alignParentLeft="true" 
     android:layout_marginLeft="15dp" /> 
    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/likeImage" 
     android:id="@+id/likeText" /> 
    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_below="@+id/tv_progress"> 
     <ImageButton 
      android:src="@drawable/coment" 
      android:layout_width="25dp" 
      android:layout_height="25dp" 
      android:layout_marginRight="4dp" 
      android:id="@+id/comment" /> 
     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginLeft="4dp" 
      android:id="@+id/commentText" /> 
    </LinearLayout> 
    <ImageButton 
    android:id="@+id/repostImage" 
    android:background="#ffffff" 
    android:src="@drawable/repost" 
    android:layout_width="25dp" 
    android:layout_height="25dp" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="45dp" /> 
    <TextView 
     android:layout_toRightOf="@+id/repostImage" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="77" 
     android:id="@+id/repostText" /> 
</RelativeLayout> 

解決しましたが、ImageViewはまだ修正されていません。そのためここでは、固定TextView

<ImageButton 
     android:id="@+id/repostImage" 
     android:layout_toLeftOf="@+id/repostText" 
     android:background="#ffffff" 
     android:src="@drawable/repost" 
     android:layout_width="25dp" 
     android:layout_height="25dp" /> 
<TextView 
     android:layout_alignParentRight="true" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/repostText" 
     android:layout_marginLeft="10dp" 
     android:layout_marginRight="15dp" /> 

の問題で追加画面です: enter image description here

私のソリューション だけandroid:layout_alignParentRight="true"

+0

あなたの期待するビューのスクリーンショットを入れてコードを確認する – Stallion

+0

親ビューとして 'RelativeLayout'を使う – Gattsu

+0

@maven私はRelativeLayoutを使う。私は完全なコードを追加しました –

答えて

1

使用このコードでLinearLayoutの右ボタンandtのTextViewを包む

<?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="match_parent" 
    > 
<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:gravity="center" 
    android:layout_alignParentRight="true" 
> 
<ImageButton 
    android:id="@+id/repostImage" 
    android:background="#ffffff" 
    android:src="@drawable/repost" 
    android:layout_width="25dp" 
    android:layout_height="25dp" 
    android:layout_alignParentRight="true" 
    android:layout_marginRight="45dp" /> 
<TextView 
    android:layout_toRightOf="@+id/repostImage" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="77" 
    android:id="@+id/repostText" 
    android:layout_marginLeft="15dp" /> 
</LinearLayout> 
</RelativeLayout> 
+0

ありがとうございますが、画面の右側に配置します。 LinearLayoutでandroid:layout_alignParentLeft = "true"をandroidに変更した理由:layout_alignParentRight = "true" –

関連する問題