View Full Version : سایزهای مختلف صفحه نمایش
smemamian
یک شنبه 15 دی 1392, 19:36 عصر
سلام دوستان
من تمامی راهنماهای اندروید (http://developer.android.com/guide/practices/screens_support.html) رو خوندم ولی متوجه بعضی مسائل نشدم.
مثلاً قرار هست برنامه ای بنویسیم که گوشی های از api 11 به بالا رو پشتیبانی کنه !
خب قسمت drawable باید به صورت زیر باشه :
http://www.uplooder.net/img/image/54/217aa9e68803c4ccbb451ad8ef3d0084/Capture.JPG
ولی قسمت layoutها چطوری باید باشه؟
سایت توسعه دهنده پیشنهاد کرده بود بجای :
res/layout/my_layout.xml // layout for normal screen size ("default")
res/layout-small/my_layout.xml // layout for small screen size
res/layout-large/my_layout.xml // layout for large screen size
res/layout-xlarge/my_layout.xml // layout for extra large screen size
از :
sw<N>dp
استفاده کنیم.
خب الان چون من می خوام گوشی های بالای api 11 رو برنامه پشتیبانی کنه باید چه مقادیری
رو بجای بذارم؟
uzer68
یک شنبه 15 دی 1392, 20:50 عصر
برای اینکه برنامه شما از سایزهای مختلف پشتیبانی کنه باید
* فاصله ها رو توی طراحی layoutتون با dp قرار دهید، اینطوری فاصله ها بر اساس رزولوشن نمایشگر اعمال میشه.
* تو پوشههای مختلف drawable عکسهای layoutتون رو با سایزهای مختلف قرار بدین.
* همچنین باید برای سایزهای مختلف layoutهای مختلف مناسب با اون سایز درست کنین:
در اندروید ورژن 3.2 و بالاتر باید layoutتون رو توی پوشه هایی مثل layout-sw600 و غیره بریزید. در layout-sw600، عدد 600 تعداد پیکسلهای عرض دستگاه است که برای تبلت است. شما پوشه هایی با اندازه عرضهای مختلف درست کنین Layoutتون رو توش بذارین.
اگر از اندروید پایینتر از 3.2 استفاده میکنین باید مثل گفته شما در بالا از layout-large و غیره استفاده کنین.
در ضمن اگر برنامتون از اندروید 2.1 و بالاتر پشتیبانی میکنه باید دو سری پوشه فوق رو درست کنین. یعنی layout-large و غیره --- layout-sw600 و غیره
smemamian
دوشنبه 16 دی 1392, 00:42 صبح
الان من یه مشکلی دارم !
یه AVD ساختم با مشخصات زیر :
114922
لی اوت من به شکل زیره :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_gravity="center_vertical"
tools:context=".MainActivity" >
<!-- One Two Button -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
>
<RelativeLayout
android:id="@+id/one_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:layout_marginRight="10dp"
android:padding="20dp" >
<ImageView
android:id="@+id/one_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/two_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:padding="20dp" >
<ImageView
android:id="@+id/two_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
</LinearLayout>
<!-- Three Four Button -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
>
<RelativeLayout
android:id="@+id/three_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:layout_marginRight="10dp"
android:padding="20dp" >
<ImageView
android:id="@+id/three_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/four_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:padding="20dp" >
<ImageView
android:id="@+id/four_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
</LinearLayout>
<!-- Five Six Button -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:layout_marginTop="20dp"
>
<RelativeLayout
android:id="@+id/five_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:layout_marginRight="10dp"
android:padding="20dp" >
<ImageView
android:id="@+id/five_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/six_btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/border"
android:padding="20dp" >
<ImageView
android:id="@+id/six_picture"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>
توی این AVD اینجوری نشون میده !
114923
طبق خود داکیومنت اندروید باید این لی اوت واسه هر سایزی پیش فرض باشه و scale بشه !!! ولی نشده !!
114924
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.ex30"
android:versionCode="1"
android:versionName="1.0" >
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true"
android:xlargeScreens="false" />
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="11" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.ex30.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
smemamian
دوشنبه 16 دی 1392, 10:28 صبح
دوستان فکر کنم از drawable-mdpi بجای drawable-xhdpi استفاده می کنه :-؟
vBulletin® v4.2.5, Copyright ©2000-1404, Jelsoft Enterprises Ltd.