ImageView的(QUOT; headbar")不同的屏幕等 [英] ImageView ("headbar") different screens etc
问题描述
我只想做一个ImageView的作为我headbar ...它应该只是填写他的父母线性布局..显然事实并非如此。
I just want to make an ImageView as my headbar ... it should just fill out his parent linear-layout.. apparently it does not.
有没有办法告诉scaleType只是为了满足其母公司布局? (XML中的最佳解决方案)我看到的是一个程序,解决方案,设置scaleType补......但似乎没有匹配的XML属性,还是没有我看看吗?
is there any way to tell the scaleType just to fit its parent-layout? (best solution in XML) i saw the was a programming-solution which setting the scaleType to "fill" ... but there seems to be no matching xml-attribute, or didn't i see it?
<?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>
有关它的任何想法/解决方案?我想我不必介意宽高比,因为我9patched整个事情..所以应该不会介意。
any thoughts/solutions about it? I thought i don't need to mind about the aspect ratio because I 9patched the whole thing.. so it shouldn't mind.
编辑:这似乎更好地工作时,我使用的ImageButton代替的ImageView的...但是,我得到了较低-size屏幕的问题......他们似乎不介意我9patching ...笑
edit: it seems to work better when i use an ImageBUtton instead of an imageview... however, i got problems on lower -size screens... they seem to don't mind my 9patching... lol
推荐答案
您需要在一般使用三种类型的布局
You need to use three types of layouts in general
-
布局华电国际
layout-hdpi
布局于mdpi
布局LDPI
此外,你需要使用一般三个值的布局
Also you need to use three values layouts in general
-
值,华电国际
values-hdpi
价值观MDPI
价值观LDPI
下面我为LDPI设备标题说明你有做你的设备华电国际,MDPI等
Here i explain for LDPI Device Header you have to do for all you device HDPI,MDPI, etc
例如简单的XML有图片为头:布局LDPI - 标题
For example simple xml that has Image as Header : layout-ldpi - Header
<?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包含
Similarly values-ldpi contains
<?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>
同样,对于Styles.xml:
Similarly for Styles.xml :
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<style name="WindowTitleBackground" parent="android:WindowTitleBackground">
<item name="android:background">@android:color/transparent</item>
</style>
在您的Manifest.xml包括此行:
In your Manifest.xml include this Line :
<application android:icon="@drawable/vmi_icon" android:label="@string/app_name" android:theme="@style/MyTheme" >
把Styles.xml和的themes.xml里面的价值观LDPI 文件夹
我标题所示为LDPI设备同样需要创建 MDPI 和华电国际设备
I shown Header for ldpi device similarly you need to create for MDPI and HDPI device
改变应该在这条线全部进行
changes should be made in this line of all
如果这是华电国际:
<item name="android:windowTitleSize">100px</item>
如果是MDPI:
<item name="android:windowTitleSize">70px</item>
同样,对于header.xml:
Similarly for header.xml :
如果这是华电国际:
android:layout_height="100px"
如果是MDPI:
android:layout_height="70px"
让我知道如果你需要进一步澄清。
感谢Venky。
Let me know if you need further clarifications. Thanks Venky.
这篇关于ImageView的(QUOT; headbar&QUOT;)不同的屏幕等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!