how to make android app density independence? -


i developing photo editor in android studio . have images , icons on screen not fit other screens(different sizes). have included following support screen code in manifest.xml file

<supports-screens      android:anydensity="true"      android:largescreens="true"      android:normalscreens="true"      android:resizeable="true"      android:smallscreens="true"      android:xlargescreens="true" /> 

i came know density independence way rid of this. don't know how proceed further .please me steps make app density independence? activity_main.xml

android:layout_width="match_parent" android:layout_height="match_parent"  android:orientation="vertical"  android:gravity="center_vertical|center"  android:background="#403e3e">  <linearlayout      android:layout_margintop="30px"      android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:orientation="vertical"      android:gravity="center">       <seekbar          android:layout_width="300dp"          android:layout_height="wrap_content"          android:layout_gravity="center"          android:max="200"          android:progress="100"          android:id="@+id/seekbar1" />  </linearlayout>  <linearlayout      android:id="@+id/middle_layout3"      android:layout_width="match_parent"      android:layout_height="wrap_content"      android:orientation="horizontal"      android:gravity="center"      android:layout_gravity="center_horizontal">      <imageview      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:layout_marginleft="10px"      android:id="@+id/imageview2"      android:scaletype="fitcenter"      android:adjustviewbounds="true"      android:src="@drawable/ic_launcher"      android:layout_gravity="center_vertical"      android:background="#ff0e0e0e" />  <slidingdrawer      android:layout_width="wrap_content"      android:layout_height="wrap_content"      android:content="@+id/content"      android:handle="@+id/handle"      android:id="@+id/slidingdrawer"      android:orientation="horizontal"      android:alpha="0.5"      android:layout_gravity="right|top">      <linearlayout          android:id="@+id/content"          android:layout_width="fill_parent"          android:layout_height="fill_parent"          android:orientation="vertical"          android:background="#11111111"          android:gravity="center">          <imageview              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:id="@+id/brighticn"              android:scaletype="fitcenter"              android:adjustviewbounds="true"              android:background="@drawable/brighticon"              android:layout_gravity="center_vertical" />           <imageview              android:layout_width="wrap_content"              android:layout_height="wrap_content"              android:id="@+id/filtericn"              android:background="@drawable/filters" />      </linearlayout>      <imageview          android:layout_width="wrap_content"          android:layout_height="wrap_content"          android:id="@+id/handle"          android:background="@drawable/move" />  </slidingdrawer>  </linearlayout>  <linearlayout      android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:orientation="horizontal"      android:gravity="bottom"      android:layout_gravity="bottom">  <horizontalscrollview      android:layout_width="fill_parent"      android:layout_height="wrap_content"      android:id="@+id/scrollview"      android:layout_gravity="bottom"      android:background="#ff030101">       <linearlayout          android:id="@+id/sublayout"          android:layout_width="fill_parent"          android:layout_height="wrap_content"          android:orientation="horizontal"          android:background="#ff030101">          <button             android:id="@+id/buttonhide"              android:text="txt"              android:layout_width="wrap_content"              android:layout_height="wrap_content" />        </linearlayout>  </horizontalscrollview>  </linearlayout> 

to able have density independent app, need provide resources in different resolutions. android smart on handling those.

when adding images should create smaller images, or larger images, based on format of screen want support , put them in specific folder format. this:

  • res/
    • drawable/
      • icon.png
      • background.png
    • drawable-hdpi/
      • icon.png
      • background.png

this make android use drawable/icon.png when have other screen density hdpi. use drawable-hdpi/icon.png specific type of screen.

to understand better, can read detailed guide android docs: http://developer.android.com/guide/topics/resources/providing-resources.html


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -