2011-12-20 4 views
3

現在、1つのアンドロイドアプリケーションを作成しています。タイトルバーのすべてのコンテンツはwindow_title.xmlに保持されていますので、LinearLayoutが設定されています:paddingLeft = "5dip"そして今、私はこのtitleBrightの右側にimageViewをロードする必要があります。私はこのpaddingLeftを上書きすることができます。左にテキストとイメージが必要ですが、右にも必要です。ここでAndroid上のLinearLayoutにPaddingLeftを上書きする

は、現在のxmlです:私が正しくあなたの質問を理解していれば

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="50dip" 
    android:gravity="center_vertical" 
    android:paddingLeft="5dip" 
    android:background="#222222"> 

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

    <TextView   
     android:text="TextTexast" 
     android:textSize="10pt" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_weight="1" 
     android:paddingLeft="5dip" 
     android:textColor="#F7F7F7" 
     /> 

</LinearLayout> 

答えて

3

、あなたはタイトルバーのTextViewの右側に表示さImageViewのためにいくつかのパディングを適用するために探しています。あなたはこのようなあなたのルートLinearLayoutandroid:paddingRightを使用することができます。

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="50dip" 
    android:gravity="center_vertical" 
    android:paddingLeft="5dip" 
    android:paddingRight="5dip 
    android:background="#222222"> 

また、あなたは右に整列するImageViewandroid:paddingRight属性を指定することができます。

+0

そのように試してみてください。しかし、同じこと。ここにあなたを助ける写真があります:http://shrani.si/f/k/r5/2y9AMubw/img.pngですから、この灰色の形を左隅から右隅に移動する必要があります。そして、私はLinearLayout paddingRightでImageViewで指定した内容を無視しています。 – HyperX

+1

あなたが@HyperXのために働いていない場合、なぜそれを受け入れられた答えとしてマークしましたか? – StackOverflowed

0

グレーの数字を右に移動するには、android:layout_gravity"right"に設定します。

関連する問題