java - 如何在其父级之外获取视图的一部分?
问题描述
我试图创建一个像这样的actionBar,“这是一个网站模板”
所以我创建了一个我将膨胀的文件,action_bar.xml
A的RelativeLayout
高度为wrap_content
& 宽度为.match_parent
RelativeLayout
我尝试使用边距,但它并没有脱离 ,RelativeLayout
而是RelativeLayout
被扩展了。因此,margin
图片中的更多会导致RelativeLayout
. 有什么建议么?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageButton android:src="@drawable/roundPicture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="30sp"
android:layout_marginLeft="30sp"
android:padding="0sp"/>
<ImageButton
android:id="@+id/gearIcon"
android:layout_alignParentRight="true"
android:background="@drawable/gearICON"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10sp"
/>
</RelativeLayout>
请不要图书馆,我不是在制作应用程序,我只是想理解。
快速回顾一下。我想要第一个ImageButton
外面的一部分RelativeLayout
解决方案
检查这是否是您要查找的内容
编辑:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<ImageButton
android:id="@+id/gearIcon"
android:layout_alignParentRight="true"
android:background="@android:drawable/ic_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10sp"
/>
</RelativeLayout>
<ImageButton
android:background="@android:drawable/ic_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="30sp"
android:layout_marginLeft="30sp"
android:padding="0sp"/>
</FrameLayout>
推荐阅读
- html - 为什么线条没有出现在我的 SVG 元素中的圆圈上
- python - 如何添加超时,python discord bot
- c - printf 为变量的值返回 6422044
- c++ - e`的值在windbg中是什么意思
- bash - 一个命令在标准输出上放一个键,然后是下一个 | 使用从标准输入获取的密钥打开数据库
- javascript - TypeError:没有'new'就不能调用类构造函数DatabaseError
- ruby - 这个.all有什么原因吗?工作不正常吗?
- c++ - C++ 使用位图的最佳方式
- excel-formula - 根据excel中的键值总结值
- javascript - 新数据推送到数组时更新功能组件