我一直在尝试学习如何在Android Studios中使用相对布局。我只在其中制作了一系列线性布局的布局,我看到的所有教程都显示了如何在右上角,中间,左下角等处放置文本视图...但我想知道我是怎么做的可以将东西放在任何位置,将一堆线性布局转换为一个相对布局(例如:在父视图下放置1/3的东西)和类似的东西,但我没有找到相关信息。感谢任何有助于提升的人!
答案 0 :(得分:1)
如果您想使用 Relativelayout 和 Linearlayout 期货,您可以像这样使用 PercentRelativelayout
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%"/>
</android.support.percent.PercentFrameLayout>
你需要依赖它
compile 'com.android.support:percent:24.1.1'
答案 1 :(得分:0)
你想要实现的东西更有可能来自LinearLayout,因为它支持“weight”属性。 另一方面,RelativeLayout,顾名思义,可让您将视图与其他视图或父视图相关联。