-2

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...

4 Answers4

0

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

Junaid Hafeez
  • 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
  • see my edits. hope it will help you to get the idea. – Junaid Hafeez Mar 09 '17 at 12:35
  • 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
0

Use Constraint Layout as suggested by Junaid otherwise use weightsum properly.

Jordon
  • 191
  • 1
  • 12
0

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" />
Rajesh
  • 2,618
  • 19
  • 25
0

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