2016-05-17 14 views
-1

2つの画像とテキストを整列したい。最初の画像がコメントアウトされると、テキストと2番目の画像はカードの中央に揃えられます。しかし、最初の画像は常にカードの下部に揃えられています。私は今までのところ、すべてのレイアウトプロパティを運がないまま試しました。LinearLayoutで2つの画像とテキストを整列する

例のスクリーンショットを参照してください。私は円がOKボタンよりも大きい理由を理解していません。なぜなら、これらのファイルを開いたときに同じ寸法を持つからです。問題はどこですか?私はLinearLayoutをもっとも単純なレイアウトマネージャとして利用したいと思っています。

enter image description here

<android.support.v7.widget.CardView 
android:layout_gravity="center" 
android:layout_width="match_parent" 
android:layout_height="50dp" 
android:layout_marginRight="8dp" 
android:layout_marginLeft="8dp" 
android:layout_marginBottom="4dp" 
android:layout_marginTop="4dp" 
app:cardCornerRadius="4dp"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginLeft="16dp" 
    android:layout_marginTop="14dp" 
    android:orientation="horizontal"> 

    <ImageView 
     android:id="@+id/badge_type" 
     android:src="@drawable/ic_gold_circle" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

    <TextView 
     android:id="@+id/badge_title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginStart="10dp" 
     android:layout_marginLeft="10dp" 
     android:text="@string/badge_title_KNIGHT" 
     style="@style/PlayRecordHeader" 
     /> 

    <View 
     android:layout_width="0dp" 
     android:layout_height="0dp" 
     android:layout_weight="1" /> 

    <ImageView 
     android:id="@+id/badge_status" 
     android:src="@drawable/ic_correct" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="8dp"/> 
</LinearLayout> 
</android.support.v7.widget.CardView> 

更新layout_gravity="center_vertical"

enter image description here

+1

'' LinearLayout'アンドロイドに追加で

android:layout_marginLeft="16dp" android:layout_marginTop="14dp" 
: "center_vertical" 重力=は ' –

+0

うーん、質問と受け入れ答えの両方がdownvoted: - /私は明確な理由なしに匿名downvotesを憎みます。 –

+0

@LeosLiterak私たちが持っている会話が無意味なのは分かっています。私はあなたの "問題"について徹底した説明をしましたが、あなたはそれを全く理解していなかったと思います。今では会話全体が「否定的」な方向に向かっています。それは無意味です。ここにいる私のすべての痕跡をクリアしましょう。私はここにはいなかったのと同じように。乾杯。 –

答えて

0

と私はあなたが

android:layout_gravity="center_vertical" 

を維持し、を取り除くために持っていると思いますLinearLayout

関連する問題