Reshmin DP
Reshmin DP

Reputation: 17

How to Auto adjust Android Layout to device screen size

I have a layout with edit texts,spinners and buttons inside a linear layout. When running this app in large screen device like 480x800 and above can see all widgets in screen. But when running in small screen size device like 320x480 QVGA can't see the buttons in device. It appears outside the screen view like the attached picture. How can I resolve the issue by automatically detects and appear in to the screen? Please help..![Please see the error in picture link below]

https://i.sstatic.net/85x1W.jpg

Upvotes: 0

Views: 4021

Answers (3)

iMDroid
iMDroid

Reputation: 2128

I think you should add ScrollView above your Parent Layout so that you can scroll up to see whole layout.. something like this..

<ScrollView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

    <LineaLayout> <--your parent layout-->

      //other views....


    </LinearLayout>
</ScrollView>

Upvotes: 1

Darpan
Darpan

Reputation: 5795

You may use many ways like 1. create files such as -

res/values/dimensions.xml
res/values-sw600dp/dimensions.xml -> 7+ inches
res/values-sw720dp/dimensions.xml -> 10+ inches

Dimensions are resources files:

<dimen name="default_padding">11dp</dimen>

You can increase the dimensions by about 30% in the 600 and 720 file. Then simply used @dimen/default_padding in your layout and it will be scaled

Regarding images, either you make sure you have all your assets in all densities, or you set fixed size to you ImageView's and appropriate scaleType

  1. Create different layouts for different screens, and different images as well.

  2. Read Android documentation tips

  3. Provide layout weights for dimensions. You can google how to do it.

Upvotes: 0

Miki Franko
Miki Franko

Reputation: 687

You can wrap your layout in ScrollView, Then in case that the screen is too small you will see scroll on screen.

Upvotes: 0

Related Questions