Reputation: 39
I have been trying to learn how to use relative layouts in Android Studios. I have only made layouts with a bunch of linear layouts inside of them and all of the tutorials I have seen display how to put a text view in the top right corner, center, bottom left etc...but I want to know how I can place things in any location to convert a bunch of linear layouts to one relative layout(example: Place something 1/3 down the parent view) and things like that but I have had no luck finding information on that. Thanks to anyone who helps in advanced!
Upvotes: 0
Views: 53
Reputation:
If you want to use Relativelayout and Linearlayout futures you can use PercentRelativelayout like this
<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>
you need dependency of it
compile 'com.android.support:percent:24.1.1'
Upvotes: 1
Reputation: 361
The thing which you want to achieve is more possible from LinearLayout, as it supports "weight" property. RelativeLayout on the other side, as the name suggests lets you to place your views in relation to other views or parent.
Upvotes: 0