2011-08-11 27 views
0

ImageViewを私のヘッドバーにしたいだけです...それはちょうど彼の親の線形レイアウトを記入すべきです。明らかにそうではありません。ImageView( "headbar")異なる画面など

スケールタイプを親レイアウトに合わせる方法はありますか? (XMLで最高のソリューション)私は、 "fill"にscaleTypeを設定するプログラミングソリューションを見ました...しかし、一致するxml属性がないようですか、それを見ませんでしたか?

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"> 
    <LinearLayout 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:layout_weight="1" 
     android:id="@+id/linearlayoutmain"> 
    <ImageView 
     android:layout_marginTop="0dp" 
     android:src="@drawable/headbar" 
     android:id="@+id/mainheadbar" 
     android:scaleType="fitStart" 
     android:paddingTop="0dp" 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     /> 
    </LinearLayout> 
    <LinearLayout 
     android:layout_height="fill_parent" 
     android:layout_width="fill_parent" 
     android:layout_weight="7" 
     android:layout_below="@id/linearlayoutmain"> 
    </LinearLayout> 
</RelativeLayout> 

それに関する考え方や解決策はありますか?私は全部9つのパッチを当てたのでアスペクト比について気にする必要はないと思ったので、気にしないでください。

編集:画像ビューの代わりにImageBUttonを使用するとうまくいくように見えますが、サイズの小さい画面で問題が発生しました...私の9patching ...気にしないようです... lol

答えて

1

あなたは一般的な

  1. レイアウト-hdpiにレイアウトの3種類を使用する必要が

  2. レイアウト-MDPI

  3. レイアウトLDPI

また、あなたが

  1. 値-hdpi

  2. 値-MDPI

  3. 値-LDPI

一般的に3つの値のレイアウトを使用する必要があります彼女EIヘッダーなどの画像がありますたとえば、単純なXML用など

、あなたはすべてのあなたのデバイスHDPI、MDPIのためにしなければならないLDPIデバイスヘッダの説明:レイアウト-LDPI - ヘッダー

同様
<?xml version="1.0" encoding="UTF-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="fill_parent" android:layout_height="50px" 
      android:orientation="horizontal" > 

    <ImageView android:id="@+id/header_main_title" android:layout_marginTop="10dip" 
       android:layout_width="wrap_content" android:layout_height="50dip" 
       android:background="@drawable/header_image" 
       android:layout_centerHorizontal="true" android:layout_marginRight="10dip" 
       /> 

値-LDPIでのstyles.xmlため

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

    <resources> 
    <style name="MyTheme" parent="android:Theme"> 
     <item name="android:windowTitleSize">50px</item> 
     <item name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground 
     </item>  
    </style> 
    </resources> 

同様に含ま:

<application android:icon="@drawable/vmi_icon" android:label="@string/app_name" android:theme="@style/MyTheme" > 

はのstyles.xmlとテーマを置く:あなたのManifest.xmlで

この行が含まれています。 値-LDPIフォルダ

の内部XML私はLDPIデバイス用のヘッダーを示す同様にあなたが

変更はすべて

のこの行になされるべきであるMDPIHDPIデバイス用に作成する必要があります

<item name="android:windowTitleSize">100px</item> 

それはMDPIだ場合::それはHDPIなら

header.xmlのための同様
<item name="android:windowTitleSize">70px</item> 

:それはHDPIだ場合

:それはMDPIなら

android:layout_height="100px" 

android:layout_height="70px" 

は、あなたがさらに明確化が必要な場合は、私に教えてください。 Venkyに感謝します。

+0

MDPIデバイスの場合、70dpが正しく適合します。 – Venky

+0

最初のところにありがとう..多分私の2番目の質問で私を助けることができる.. http://stackoverflow.com/questions/7030772/9patching-cant-have-more-than-one-marked-region-along-エッジ – Aeefire

関連する問題