简体   繁体   中英

Designing an app for Android Phone and Tablet

I will start with very simple basic question, How do i keep an button image for tablet and phone,

I have an button which i want to use width as full_parent, which make my button good, Now what happen if I have different - 2 layout.

I am aware of multiple layout concept, but the how can i ensure that my button image will not stretch to fit into my screen

So I thought to use dpi, but dpi will not solve problem

手机测试图

if you view this image as Phone app, and button "Test this button" and about layout "test" is similiar in width,

Now what is best approach to achieve the same behavior in tablet also.

will it work for all size of devices? or do we need to go with different approach?

Most of the problem i am facing is because of static images, I tried to use different-2 dpi for this, but I think dpi is not device size dependent, because same width device can have different-2 dpi

I need to understand approach for implementing on one app for each device.

Add into the drawable folder name with xyz.xml

<?xml version="1.0" encoding="utf-8"?>
    <layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item>
        <shape android:shape="rectangle">
            <gradient android:startColor="#000000" android:endColor="#333333" android:angle="90"/>
            <corners android:radius="5dp"/>
        </shape>
    </item>
</layer-list>

And in your layout where you crate the button add into

android:background="@drawable/xyz"

You'll get what you want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM