[英]Layout with image and “bottom bar” issues
我对整个Android事情都很陌生,所以我希望这是显而易见的,因为我还没能在网上找到解决方案。
我正在创建一个包含ImageView和“底栏”的视图。 我遇到的问题是,由于图像比屏幕大,我更喜欢使用类似“fill_parent”或“wrap_content”的东西。 理想情况下,我会将ImageView的高度设置为“fill_parent-44px”,但我还没有找到在XML中执行此操作的方法。
最终我计划让ImageView功能具有多点触控变焦,因此不能选择为不同的屏幕分辨率调整图像大小。
谢谢你的帮助。
使用RelativeLayout
很容易做到这一点:
<?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="fill_parent">
<View android:id="@+id/bottombar"
android:background="#FFCC00"
android:layout_height="40dp"
android:layout_width="fill_parent"
android:layout_alignParentBottom="true" />
<ImageView android:id="@+id/image"
android:src="@drawable/someimage"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="@id/bottombar"/>
</RelativeLayout>
这里重要的是android:layout_alignParentBottom
和android:layout_above
(有关所有可能的布局属性,请参阅RelativeLayout.LayoutParams )。
给定正确的RelativeLayout
参数,或多或少地忽略了android:layout_height="fill_parent"
,它只需要在那里取悦Android UI系统。
android:background
仅用于在UI设计器中突出显示,而底bottombar
View
可以被任何其他视图替换,如TextView
, LinearLayout
等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.