繁体   English   中英

布局与图像和“底栏”问题

[英]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_alignParentBottomandroid:layout_above (有关所有可能的布局属性,请参阅RelativeLayout.LayoutParams )。

给定正确的RelativeLayout参数,或多或少地忽略了android:layout_height="fill_parent" ,它只需要在那里取悦Android UI系统。

android:background仅用于在UI设计器中突出显示,而底bottombar View可以被任何其他视图替换,如TextViewLinearLayout等。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM