I am trying to create an app...But when I use to test my app on various devices the app is not appear in full screen/same resolution as the device having...
-
Share your layout here. – Nilay Vishwakarma Mar 09 '17 at 11:41
-
3Possible duplicate of [How to support different screen size in android](http://stackoverflow.com/questions/8255985/how-to-support-different-screen-size-in-android) – jayeshsolanki93 Mar 09 '17 at 11:49
-
You can read more about designing layouts for different screen sizes here https://developer.android.com/training/multiscreen/screensizes.html and here https://developer.android.com/guide/practices/screens_support.html – jayeshsolanki93 Mar 09 '17 at 11:54
-
@jayeshsolanki93 I tried this wrap_content and match_content concept but not able to add four button 2horizontal and 2vertical....And also if I define button size then it will not work for every device! – Vinit Maheshwari Mar 09 '17 at 11:59
-
@NilayVishwakarma Not able to upload images... – Vinit Maheshwari Mar 09 '17 at 12:00
-
@VinitMaheshwari share your source at first, then share the image through imgur – xiaoyaoworm Mar 09 '17 at 18:31
4 Answers
you may use ConstaintLayout
to make a responsive UI, you can follow below official docs
https://developer.android.com/training/constraint-layout/index.html
An other option is PercentRelativeLayout
https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html
For a 3*3 matrix, you can use Tablelayout
something like this
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow>
<TextView
android:text="first" />
<TextView
android:text="second"
android:gravity="center" />
<TextView
android:text="third"
android:gravity="right" />
</TableRow>
<TableRow>
<TextView
android:text="first" />
<TextView
android:text="second"
android:gravity="center" />
<TextView
android:text="third"
android:gravity="right" />
</TableRow>
<TableRow>
<TextView
android:text="first" />
<TextView
android:text="second"
android:gravity="center" />
<TextView
android:text="third"
android:gravity="right"/>
</TableRow>
</TableLayout>
or you may use combination of linearlayouts
with weightSum
and layout_weight

- 1,618
- 1
- 16
- 25
-
Can u send me a main activity layout xml which have 3*3 matrix type buttons? – Vinit Maheshwari Mar 09 '17 at 12:02
-
better to search and explore things yourself, if you still couldn't find make things better, share your code and ask to improve. happy coding :) – Junaid Hafeez Mar 09 '17 at 12:19
-
-
I'm adding Button(9 buttons) in a 3*3 matrix form..With some widht and height but when I try to run app in different devices of different screen size I saw the buttons are not adjusting to screen size they got out of the screen or shrinks – Vinit Maheshwari Mar 09 '17 at 18:26
Use this library for dp
you not need to make different layout for each resolution https://github.com/intuit/sdp
dependencies {
compile 'com.intuit.sdp:sdp-android:1.0.4'
}
Example
<LinearLayout
android:id="@+id/give_us_a_review_landmine_main_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical"
android:paddingBottom="@dimen/_27sdp"
android:paddingLeft="@dimen/_43sdp"
android:paddingRight="@dimen/_43sdp"
android:paddingTop="@dimen/_50sdp" />

- 2,618
- 19
- 25
-
-
First I went to gradle than wrote the code than clicked on button syn now it shows error – Vinit Maheshwari Mar 10 '17 at 05:28
-
error? what error appear?, please check updated answer or link contain sample inside git repo. – Rajesh Mar 10 '17 at 05:33
-
Sir my main problem is I'm adding 9 buttons with some size and background but when I run the app in different devices the buttons goes out of the screen or shrinks...I don't know what to do – Vinit Maheshwari Mar 10 '17 at 05:36
I'm adding Button(9 buttons) in a 3*3 matrix form..With some widht and height but when I try to run app in different devices of different screen size I saw the buttons are not adjusting to screen size they got out of the screen or shrinks