There is an application layout for sizes 720x1280 px
The application on different densities looks different, which is in principle understandable.
In the case of drawable elements, you need to create folders with the necessary density of type res / drawable-mdpi / and the sizes of elements in pixels multiply but the corresponding factor.
In the case of the layout, I understand you need to do the same, folding the layout for the desired size - in the right
res/layout/my_layout.xml // layout for normal screen size ("default") res/layout-large/my_layout.xml // layout for large screen size res/layout-xlarge/my_layout.xml // layout for extra-large screen size
or
res/layout-sw600dp/ минимальная ширина res/layout-h600dp/ минимальная высота
Here http://developer.android.com/intl/ru/guide/practices/screens_support.html says that the second option is preferable.
There is a mess in my head, but I can understand where to start and what to build on! How to determine this minimum width, and how to proceed from this layout if the layout is in pixels, how to translate them into (dp).
Before that, I just took the size from the layout in pixels and divided it into two, but something tells me that it was wrong.
activity_main.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:fitsSystemWindows="true" tools:context=".activities.MainActivity" android:background="@color/colorWhite"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:id="@+id/linearLayout" android:layout_below="@+id/appBarLayout" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:background="@drawable/header_button_shape_baground" > <Button android:text="НАЧАТЬ" android:id="@+id/btnStart" android:layout_width="300dp" android:layout_height="40dp" android:layout_marginTop="10dp" android:layout_marginBottom="10dp" android:layout_marginLeft="32dp" android:layout_marginRight="32dp" android:textColor="@color/colorWhite" android:background="@drawable/button_start_background" android:textStyle="bold" /> </LinearLayout> <RelativeLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/linearLayout" android:layout_alignParentBottom="true"> <ListView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/listView" android:divider="@android:color/transparent" android:dividerHeight="5dp" android:focusable="false" /> </RelativeLayout> </RelativeLayout>
item_list.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:custom="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="97dp" android:orientation="horizontal" android:background="@color/colorWhite"> <!-- android:background="@drawable/item_shape_baground"--> <!-- ListRow Left sied Progress Bar --> <RelativeLayout android:id="@+id/progressbar" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentStart="true" android:gravity="center_vertical" android:paddingLeft="16dp" > <com.github.lzyzsd.circleprogress.CircleProgress android:id="@+id/donut_progress" android:layout_width="40dp" android:layout_height="40dp" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_centerVertical="true" custom:donut_progress="70" custom:circle_text_size="14sp" custom:circle_finished_color="@color/colorGreen" custom:circle_unfinished_color="@color/colorBackgroundDarckGrey" /> </RelativeLayout> <!-- Title of package--> <RelativeLayout android:id="@+id/titleDescription" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/linearLayoutTop" android:layout_centerVertical="true" android:layout_toRightOf="@+id/progressbar" android:gravity="center_vertical" android:orientation="horizontal" android:paddingLeft="16dp" > <TextView android:id="@+id/title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:text="Rihanna Love the way" android:textColor="@color/colorFontBlue" android:textSize="16sp" android:typeface="sans" /> <TextView android:id="@+id/description" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/title" android:layout_marginTop="6dp" android:singleLine="false" android:text="Just gona stand there and ..." android:textColor="#535353" android:textSize="13sp" /> </RelativeLayout> <!--Buy and about--> <RelativeLayout android:id="@+id/buyCase" android:layout_width="231dp" android:layout_height="match_parent" android:layout_centerVertical="true" android:gravity="center_vertical|right" android:paddingRight="16dp" android:layout_alignParentEnd="true" android:layout_alignParentRight="true" > <!-- Buy button --> <Button android:id="@+id/btnBuy" android:layout_width="62.5dp" android:layout_height="26dp" android:background="@drawable/button_board_baground" android:text="4.99 $" android:textColor="@color/colorFontBlue" /> <!-- Short description about package --> <TextView android:id="@+id/count" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:text="230 words" android:textSize="12dp" /> </RelativeLayout> <!-- SHADOWS --> <LinearLayout android:id="@+id/shadowLayoutBottom" android:layout_width="match_parent" android:layout_height="5dp" android:layout_alignParentBottom="true" android:background="@drawable/shadow_bottom" android:orientation="horizontal" /> <LinearLayout android:id="@+id/linearLayoutTop" android:layout_width="match_parent" android:layout_height="1.7dp" android:layout_alignParentTop="true" android:background="@drawable/shadow_top" android:orientation="vertical" /> </RelativeLayout>
activity_learn.xml
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorBackgroundGrey" > <android.support.design.widget.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:theme="@style/AppTheme.AppBarOverlay" android:id="@+id/appBarLayout" android:background="@drawable/header_button_shape_baground"> <android.support.v7.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="?attr/colorPrimary" app:popupTheme="@style/AppTheme.PopupOverlay" /> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/pager" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_below="@+id/appBarLayout" android:layout_above="@+id/btnNext" /> <Button android:id="@+id/btnNext" android:text="NEXT" android:layout_width="match_parent" android:layout_height="83dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:layout_alignParentBottom="true" android:layout_marginBottom="10dp" android:textSize="20dp" android:background="@color/colorWhite"/> </RelativeLayout>
fragment_learn_activity.xml
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/content" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/colorBackgroundGrey" > <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:gravity="center_horizontal|center_vertical" > <View android:layout_width="match_parent" android:layout_height="326dp" android:id="@+id/backView" android:background="@color/colorWhite" android:layout_alignParentTop="true" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" /> <TextView style="?android:textAppearanceMedium" android:lineSpacingMultiplier="1.2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Lorem ipsum" android:id="@+id/mainWord" android:gravity="center_horizontal" android:layout_alignParentTop="true" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="102.5dp" android:textColor="@color/colorBlack" android:textSize="44sp" /> <TextView android:id="@+id/translateWord" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="dolor sit amet" android:gravity="center_horizontal" android:layout_below="@+id/mainWord" android:layout_alignParentRight="true" android:layout_alignParentEnd="true" android:layout_marginTop="29dp" android:textSize="20sp" /> <TextView android:id="@+id/textViewExample1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua" android:layout_below="@+id/backView" android:layout_alignParentLeft="true" android:layout_alignParentStart="true" android:layout_marginTop="46dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:textSize="16dp" /> <TextView android:id="@+id/textViewExample2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Ut enim ad minim veniam, quis nostrud exercitation." android:layout_below="@+id/textViewExample1" android:layout_alignParentLeft="true" android:layout_marginTop="16dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" android:textSize="16dp" /> </RelativeLayout> </ScrollView>