2012-10-25 52 views
3

我有九個補丁圖像的背景。這是802px x 286px(2px在兩個w &小時自動添加9patchtools)。九個修補圖像是否可縮小?

main.xml中的樣子:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/crown" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:background="@drawable/crown"> 
<ListView 
    android:id = "@+id/mainmenulist" 
    style="@style/MainMenuList" 
    android:dividerHeight="2.5dp"/> 
</RelativeLayout> 

的styles.xml樣子:

<resources 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<style name="MainMenuList"> 
    <item name="android:layout_width">fill_parent</item> 
    <item name="android:layout_height">fill_parent</item> 
    <item name="android:cacheColorHint">@android:color/transparent</item> 
    <item name="android:listSelector">@android:color/transparent</item> 
    <item name="android:divider">@null</item> 
    <item name="android:gravity">right</item> 
</style> 
<style name="MainMenuRow"> 
    <item name="android:layout_width">fill_parent</item> 
    <item name="android:layout_height">wrap_content</item> 
    <item name="android:textColor">#000000</item> 
    <item name="android:gravity">right|center</item> 
    <item name="android:padding">0dp</item> 
</style> 
</resources> 

價值觀文件夾中的themes.xml:

<resources 
xmlns:android="http://schemas.android.com/apk/res/android"> 
<style name="AppTheme" parent="android:Theme.Light.NoTitleBar.Fullscreen"> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:windowBackground">@color/mycustomblue</item> 
</style> 
</resources> 

艙單mpart .xml:

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

它的行圖像:

它的背景(冠)圖像:

輸出應該是這樣的:

但它看起來是這樣的:

我的問題是:

  1. 我的九幅圖像的背景是802x286。我的設備是Android 4.0.4和720x1280(WxH)的galaxy S3。圖像是否可以縮小以適應寬度? (換句話說,如果我使用9xatch圖像100x100的設備是200x200,我們知道它的好處並擴大規模,但問題是如果使用的設備是50x50,會發生什麼?)

  2. 爲什麼我的應用程序不是全屏嗎?

  3. 爲什麼示例文本不是中間和右對齊?

  4. 爲什麼行圖像過度放大?

+0

在9-patch圖像中,你是否打算讓內容佔據整個垂直空間(使用正確的黑色標記)? –

+0

是的,右邊的黑色標記是左邊黑色標記的前面。所以當圖像垂直縮放時,內容區域會增加。 –

+0

我不明白你的答案。文本似乎不需要插入頂部/底部區域,爲什麼不將內容設置在中間?目前的配置顯示它沒有縮放 - 內容佔據整個垂直空間。也許它與問題本身有關。 –

回答

3
  1. 我覺得九個ninepatched圖像不會收縮或伸展時,你不告訴部分horizo​​ntal.The圖像只能從只是那些2pxes按比例縮放,所以最小寬度798px,你可能需要一個較小的圖像。

  2. android:windowNoTitle控制標題欄是否顯示,而不是狀態欄。標題欄是你活動的一部分,但狀態欄是系統的一部分。你所需要的,也許安卓windowFullscreen

    <!-- Variant of {@link #Theme} with no title bar --> 
    <style name="Theme.NoTitleBar"> 
        <item name="android:windowNoTitle">true</item> 
    </style> 
    
    <!-- Variant of {@link #Theme} that has no title bar and no status bar --> 
    <style name="Theme.NoTitleBar.Fullscreen"> 
        <item name="android:windowFullscreen">true</item> 
        <item name="android:windowContentOverlay">@null</item> 
    </style> 
    
  3. 右和中間是相互矛盾的,你可能使用權| center_vertical。您是否使用單個TextView作爲列表項目,是否可以爲您提供列表項目佈局

  4. 這可能是由主題中的android:listPreferredItemHeight屬性引起的。使用明確的layout_height可以解決這個問題。

+0

1.你能解釋更多嗎?我不明白!我試試。他不工作。 4.no,問題1和問題4不相似。問題1中的數字是sample.you想象錯誤的輸出行的高度是80px.i問爲什麼行圖像過度放大? –

+0

1.您只需標記可以縮放的2pxes,這意味着其他pxes不會被縮放。 – Ponyets

+0

1.是的,我知道,而且是故意的。我想從這些2pxes的horizentaly縮放圖像。 –