Layout shown differently across devices - android

i would like to know why my fragment layout has different dimensions when I run the app on different devices. I thought using dp was enough, but now I think i've missed something.
For istance, on my Nexus 6P it looks fine, but in the AVD Emulator's Nexus 4 it looks smaller
Layout code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<Button
android:id="#+id/deleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:background="#color/colorPrimaryLight"
android:text="#string/delete_button" />
<Button
android:id="#+id/moveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="15dp"
android:layout_toRightOf="#id/deleteButton"
android:background="#color/colorPrimaryLight"
android:text="#string/move_button" />
<Button
android:id="#+id/copyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/deleteButton"
android:layout_gravity="center"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:background="#color/colorPrimaryLight"
android:text="#string/copy_button" />
<Button
android:id="#+id/renameButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/moveButton"
android:layout_gravity="center"
android:layout_margin="15dp"
android:layout_toRightOf="#id/copyButton"
android:background="#color/colorPrimaryLight"
android:text="#string/rename_button" />
</RelativeLayout>
EDIT: I forgot to write the code where I set the dialogFragment size.
/**
* Setting Dialog size
*/
Window window = getDialog().getWindow();
Point size = new Point();
// Store dimensions of the screen in `size`
Display display = window.getWindowManager().getDefaultDisplay();
display.getSize(size);
window.setLayout((int) (size.y * 0.40), (int) (size.x * 0.60));
window.setGravity(Gravity.CENTER);

Most of your elements width and height seems to wrap_content, so i would check the Font configured in your emulator by default, if its size is smaller, the whole content will be small.

Related

Android Studio: Issues with widgets position - How to resize based on screen size?

Im new with Android programming on Android Studio and this seems to be simple question.
In Swift I used to get screen WIDTH and HEIGHT to put all my widgets on screen position and resize them, which in my opinion is a nice way to do that.
Here I don't know how to do that.
Ive made this screen here on XML file, this screen is the PREVIEW:
Ive set the buttons like this:
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="match_parent"
android:scaleType="fitXY"
android:alpha="0.7"
android:src="#mipmap/imgbackgroundstartview"
android:id="#+id/imgBackgroundStartView"
android:layout_height="wrap_content"/>
<ImageView
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#mipmap/btnstartcpr"
android:id="#+id/imgStartViewStartVisible"
android:layout_height="wrap_content"/>
<ImageView
android:layout_width="match_parent"
android:layout_centerHorizontal="true"
android:src="#mipmap/imgstartviewtitle"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="400dp"
android:id="#+id/imgStartViewTitle"
android:layout_height="wrap_content"/>
<TextView
android:layout_width="match_parent"
android:layout_centerVertical="true"
android:text="START"
android:layout_centerInParent="true"
android:gravity="center_horizontal"
android:textColor="#ffffffff"
android:textStyle="bold"
android:fontFamily="sans-serif-medium"
android:textSize="36dp"
android:layout_height="wrap_content" />
<Button
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="420dp"
android:layout_marginRight="250dp"
android:layout_marginBottom="20dp"
android:id="#+id/btnLoginStartView"
android:background="#mipmap/imgstartviewlogin"
android:layout_height="wrap_content"/>
</RelativeLayout>
However when I run the program it has a different positioning and sizes:
So short question: how to do the same as I was doing on SWIFT, ie:
Set button height as 10% of screen height;
Set button width as 50% of screen width;
Position button on point (width: 50% of screen width, height: 50% of screen height), which is middle of screen.
The answer could be programmatically or on XML file, both works for me.
Thanks in advance!

Setting ListView Height based on items gives extra space at the end in Android Nougat device

I am using the below function to set the height of my ListView dynamically based on the number of items in the ListView.
public boolean setListViewHeightBasedOnItems(ListView listView, String select) {
MyListAdapter adapter = (MyListAdapter) listView.getAdapter();
if (adapter != null) {
int numberOfItems = adapter.getCount();
// Get total height of all items.
int totalItemsHeight = 0;
for (int itemPos = 0; itemPos < numberOfItems; itemPos++) {
View item = adapter.getView(itemPos, null, listView);
float px = 300 * (listView.getResources().getDisplayMetrics().density);
item.measure(View.MeasureSpec.makeMeasureSpec((int) px, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED));
totalItemsHeight += item.getMeasuredHeight();
}
// Get total height of all item dividers.
int totalDividersHeight = listView.getDividerHeight() *
(numberOfItems - 1);
// Get padding
int totalPadding = listView.getPaddingTop() + listView.getPaddingBottom();
// Set list height.
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalItemsHeight + totalDividersHeight + totalPadding; // +50
listView.setLayoutParams(params);
listView.requestLayout();
return true;
} else {
return false;
}
}
The above function works well on the device with there screen density mentioned below along with the OS.
Moto E3 Power (Android 6.0, 720 x 1280 pixels, 5.0 inch screen).
Lenovo A6010 (Android 5.0.2, 720 x 1280 pixels, 5.0 inch screen).
Samsung Tablet SM T113 (Android 4.4.4, 600 x 1024 pixels, 7.0 inch
screen).
But, When I run the same on the Device with Android Nougat (7.0, 7.1.1), I get empty spaces below the last item of my ListView. That is, the height is set more than required.
The below screen shot explains what I am facing.
The Devices which are giving this issue are listed below:-
Moto E4 Plus (Android - 7.1.1, 720 x 1280 pixels, 5.5 inch screen).
Moto E5 Plus (Android - 7.0, 1080 x 1920 pixels, 5.2 inch screen).
Below is my XMl declaration of the ListView.
<ListView
android:id="#+id/lv_menu_details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginRight="#dimen/dp10"
android:divider="#color/transparent" />
Can anyone help me to resolve the issue I am facing.
Thanks in advance.
I Got the solution to the issue I was facing.
For Me the solution lied in the item list of the adapter i was using for my List View.
I was using LinearLayout with weight and to the widgets inside the LinearLayout I was giving weightsum along with some margin to the Views.
Now as the entire view was divided by weightsum views the additional margin was creating those white space at the bottom of my ListView Attributes as shown in the question posted. I replace the LinearLayout with the RelativeLayout and removed the weight attribute from the ViewGroup and weightSum attributes from my View.
And it has worked for me.
For those who are facing the same issue I am posting the xml file below for the reference:
My Old item_list.xml file Used for ListView item UI:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="horizontal"
android:paddingLeft="#dimen/dp10"
android:paddingTop="#dimen/dp10"
android:paddingBottom="#dimen/dp10"
android:paddingRight="#dimen/dp5"
android:weightSum="5">
<CheckBox
android:id="#+id/iv_checkbox"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:button="#drawable/selector_checkbox_menu_detail_item"
android:textColor="#color/white"
android:textSize="#dimen/sp18" />
<TextView
android:id="#+id/tv_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.3"
android:text="dsfdsfds"
android:textColor="#color/black"
android:textSize="#dimen/sp15" />
<TextView
android:id="#+id/tv_price"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.7"
android:text="dsfdsfds"
android:textColor="#color/black"
android:layout_marginRight="#dimen/dp10"
android:textSize="#dimen/sp15" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/layout_add_sub"
android:layout_weight="1.5"
android:orientation="horizontal"
android:weightSum="3">
<ImageView
android:id="#+id/iv_subtract"
android:layout_width="#dimen/dp30"
android:layout_height="#dimen/dp25"
android:layout_weight="1"
android:background="#drawable/button_shape"
android:padding="#dimen/dp5"
android:src="#drawable/minus" />
<TextView
android:id="#+id/tv_count"
android:layout_width="#dimen/dp30"
android:layout_height="#dimen/dp25"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/button_shape"
android:gravity="center"
android:text="1"
android:textColor="#color/black" />
<ImageView
android:id="#+id/iv_add"
android:layout_width="#dimen/dp30"
android:layout_height="#dimen/dp25"
android:layout_marginRight="#dimen/dp5"
android:layout_weight="1"
android:background="#drawable/button_shape"
android:padding="#dimen/dp5"
android:src="#drawable/add" />
</LinearLayout>
</LinearLayout>
My list_item.xml file where I replaced the LinearLayout with RelativeLayout and without using the weight and weightSum Attributes:-
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/app_background_color"
android:orientation="horizontal"
android:paddingTop="#dimen/dp10"
android:paddingBottom="#dimen/dp10">
<CheckBox
android:id="#+id/iv_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/dp5"
style="#style/CheckBoxStyle"
android:layout_marginRight="#dimen/dp5"
android:textColor="#color/app_text_color_primary"
android:textSize="#dimen/sp18" />
<TextView
android:id="#+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/iv_checkbox"
android:layout_toLeftOf="#+id/liLayRightPanel"
android:text="dsfdsfd"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp10"
android:textColor="#color/app_text_color_primary"
android:textSize="#dimen/sp15" />
<LinearLayout
android:id="#+id/liLayRightPanel"
android:orientation="horizontal"
android:layout_alignParentRight="true"
android:layout_marginRight="#dimen/dp5"
android:layout_centerVertical="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="dsfdsfd"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#color/app_text_color_primary"
android:layout_marginRight="#dimen/dp10"
android:textSize="#dimen/sp15" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/layout_add_sub"
android:layout_weight="3"
android:orientation="horizontal">
<ImageView
android:id="#+id/iv_subtract"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/circle_theme_bkgnd"
android:padding="#dimen/dp5"
android:src="#drawable/minus" />
<TextView
android:id="#+id/tv_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp5"
android:layout_marginRight="#dimen/dp5"
android:textSize="#dimen/sp16"
android:textStyle="bold"
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:text="0"
android:textColor="#color/app_text_color_primary" />
<ImageView
android:id="#+id/iv_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#drawable/circle_theme_bkgnd"
android:padding="#dimen/dp5"
android:src="#drawable/add" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Hope My Answer can help those who are facing the same issue...

Fix Layout issue

Scenario: I've four buttons arranged Relative Layout. These button's text varies through the app life which makes button shrink or expand according to text length. Using: RelativeLayout.getChildAt().setText();
Q1) But I require the each button to occupy 40% of screen width but with varying height.
Q2) And in particular my code requires to access buttons using getChildAt().
What Layout type should I use to replace RelativeLayout to set Button's width to 40% of screen width and in particular so I can access these Buttons using getChildAt()?
SomeLayout.getChildAt(); so that the Layout is immediate parent of Buttons.
<RelativeLayout android:id="#+id/buttonRelativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_margin="10dp">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/optionButton1"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/optionButton2"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/optionButton3"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="New Button"
android:id="#+id/optionButton4"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
You are actually just in luck. Android just released a new percent support library. They don't have documentation yet, but here is a good sample project that you can use to see how to go about using the library. It basically allows you to size view widgets by percentage of the screen.
https://github.com/JulienGenoud/android-percent-support-lib-sample
And here are two articles talking about it as well:
http://www.androidauthority.com/using-the-android-percent-support-library-630715/
http://inthecheesefactory.com/blog/know-percent-support-library/en
Android percent support library does a awesome work of giving percentage ratio for android widgets on the screen there by replacing our traditional LinearLayout
Github demo Here !
<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">
<TextView
android:id="#+id/fifty_huntv"
android:background="#ff7acfff"
android:text="20% - 50%"
android:textColor="#android:color/white"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_heightPercent="20%"
app:layout_widthPercent="50%" />
<TextView
android:layout_toRightOf="#id/fifty_huntv"
android:background="#ffff5566"
android:text="80%-50%"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_heightPercent="80%"
app:layout_widthPercent="50%"
/>
</android.support.percent.PercentRelativeLayout>
Really awesome !!!
Right now I can't think of any layout element that will allow you to do that.
You can try this, on your code onCreate or on one of your init views/variables method, get the buttons and set the size to 40% of the screen, something like:
Display display = getWindowManager().getDefaultDisplay();
Point screenSize = new Point();
display.getSize(screenSize);
RelativeLayout rlParent = findViewById(R.id.<RELATIVE_LAYOUT_ID>);
for(int i = 0; i < 4; i++)
{
View btn = rlParent.getChildAt(i);
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)btn.getLayoutParams();
params.width= screenSize.y * 0.4f;//40%
btn.setLayoutParams(params);
}

android how to position elements to support in all devices

I have a problem with positioning elements.
What I want to have is this image in all devices no matter screen size is.
what I have is this in two different sizes
I want my textViews and editTexts maintain their positions in the activity view. (The image 'Green-Blue-Red-Yellow square containing image' in an imageView)
and this is my layout.xml
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<TextView
android:layout_height="30dp"
android:layout_width="150dp"
android:layout_marginTop="60dp"
android:layout_marginLeft="100dp"
android:textSize="19dp"
android:textStyle="bold"
android:gravity="center"
android:text="#string/login_app_name">
</TextView>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="20dp"
android:layout_marginTop="128dp"
android:gravity="center_vertical">
<TextView
android:layout_height="20dp"
android:layout_width="100dp"
android:layout_marginLeft="35dp"
android:textStyle="bold"
android:gravity="right|center_vertical"
android:text="#string/login_username">
</TextView>
<EditText
android:layout_height="20dp"
android:layout_width="140dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="#drawable/login_edit_text">
</EditText>
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="20dp"
android:layout_marginTop="2dp">
<TextView
android:layout_height="20dp"
android:layout_width="100dp"
android:layout_marginLeft="35dp"
android:textStyle="bold"
android:gravity="right|center_vertical"
android:text="#string/login_password">
</TextView>
<EditText
android:layout_height="20dp"
android:layout_width="140dp"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:background="#drawable/login_edit_text">
</EditText>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
I suspect the problem is related to tha paddings and margins that I used to position elements. But I couldn't find any other way around.
Is there a way that you can suggest for my elements to maintain their positions in all screen sizes?
Make separate xml files for the different devices and position the images separately for the two xml's, so as to suit the different standard resolutions. link two separate classes for the two XML files, and now based on the screen resolution call either of the two classes. You can get screen res with this code:
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
final int height = dm.heightPixels;
final int width = dm.widthPixels;
Use an if-else condition and choose the class to intent to

Screen size problem

In my app which create an calendar using buttons..its working fine in all resolution except device with screen resolution 240X320..Actually it runs but some part is not visible..i have send the code and the screen shot..please anyone help me to resolve this problem..
code for xml...
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/linearLayout"
android:gravity="center_horizontal|center_vertical"
android:orientation="horizontal"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#00000000">
<Button
android:id="#+id/pBtnPrevMonth"
android:gravity="center_horizontal|center_vertical"
android:layout_width="53dp"
android:layout_height="40dp"
android:textColor="#000000"
android:background="#drawable/but_left">
</Button>
<TextView
android:gravity="center_horizontal|center_vertical"
android:id="#+id/tTextMonth"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/pBtnPrevMonth"
android:textColor="#000000">
</TextView>
<TextView
android:gravity="center_horizontal|center_vertical"
android:id="#+id/tTextYear"
android:layout_width="50dp"
android:layout_marginRight="5dp"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/tTextMonth"
android:textColor="#000000">
</TextView>
<Button
android:id="#+id/pBtnNextMonth"
android:gravity="center_horizontal|center_vertical"
android:layout_width="53dp"
android:layout_height="40dp"
android:layout_toRightOf="#+id/tTextYear"
android:textColor="#000000"
android:background="#drawable/but_right">
</Button>
</LinearLayout>
<LinearLayout
android:id="#+id/liVLayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:layout_marginTop="15dp">
</LinearLayout>
<LinearLayout android:id="#+id/linearLayout1"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical"
android:layout_marginLeft="7dp"
android:layout_marginRight="7dp"
android:layout_below="#+id/liVLayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#00000000">
<TextView
android:gravity="center_vertical"
android:text="Hello"
android:layout_marginTop="5dp"
android:id="#+id/txtView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000">
</TextView>
<TextView
android:gravity="center_vertical"
android:id="#+id/txtNoteView"
android:layout_marginTop="5dp"
android:layout_below="#+id/txtView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000">
</TextView>
<TextView
android:gravity="center_horizontal|center_vertical"
android:text="Advertisement"
android:layout_marginTop="5dp"
android:id="#+id/txtAdvView"
android:layout_below="#+id/txtNoteView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000">
</TextView>
</LinearLayout>
</RelativeLayout>
code for java......
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.calendar_frm);
txtView=(TextView) findViewById(R.id.txtView);
txtNoteView=(TextView) findViewById(R.id.txtNoteView);
txtAdvView=(TextView) findViewById(R.id.txtAdvView);
}
public boolean initDay()
{
LinearLayout layoutVertical = (LinearLayout) findViewById(R.id.liVLayout);
LinearLayout rowLayout=null;
LayoutParams param = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT,1);
//Create Button
for (i = 0; i<6; i++)
{
rowLayout = new LinearLayout(this);
rowLayout.setWeightSum(7);
layoutVertical.addView(rowLayout,param);
for(j=0;j<7;j++)
{
pBtnDay[i][j]=new Button(this);
rowLayout.addView(pBtnDay[i][j],param);
pBtnDay[i][j].setGravity(Gravity.CENTER_HORIZONTAL|Gravity.CENTER_VERTICAL);
}
}
return true;
}
snapshot which for device having resolution 240 X 400
Snapshot for device having resolution 240 X 320 is...
so by seeing this you know the problem...please suggest me..
create another xml layout file for this resolution with smaller icons or suchlike
"By default, Android resizes your application layout to fit the current device screen. In most cases, this works fine. In other cases, your UI might not look as good and might need adjustments for different screen sizes. For example, on a larger screen, you might want to adjust the position and size of some elements to take advantage of the additional screen space, or on a smaller screen, you might need to adjust sizes so that everything can fit on the screen.
The configuration qualifiers you can use to provide size-specific resources are small, normal, large, and xlarge. For example, layouts for an extra large screen should go in layout-xlarge/.
"
http://developer.android.com/guide/practices/screens_support.html#support
Done your project programatically use display metrics to get width and height
$DisplayMetrics metrics;
metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
screenWidth = metrics.widthPixels;
screenHeight = metrics.heightPixels;

Categories

Resources