بروز خطا
[message]
اشتراک در سوال
رای ها
[dataList]
عدم نمایش قسمت انتهایی ui در نمایشگر گوشی
سلام من در حال مطالعه بخش طراحی ui هستم ، این صفحه را ساختم اما قسمت انتهایی صفحه در گوشی نمایش داده نمی شود راه حل اصولی این مشکل چی میشه ؟
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btn4"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.3"
android:background="#002b6f"
android:text="0" android:textColor="#ffffff"/>
<Button
android:id="@+id/btn5"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.3"
android:background="#297aee"
android:text="0"
android:textColor="#ffffff" />
<Button
android:id="@+id/btn6"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.4"
android:background="#ba1c47"
android:text="0"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btn7"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.3"
android:background="#bb1d49"
android:text="0"
android:textColor="#ffffff" />
<Button
android:id="@+id/btn8"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.3"
android:background="#6ab51d"
android:text=" 0"
android:textColor="#ffffff" />
<Button
android:id="@+id/btn9"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.4"
android:background="#5333ae"
android:text="0"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btn1"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.3"
android:background="#2d89ef"
android:text="0"
android:textColor="#ffffff" />
<Button
android:id="@+id/btn2"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.3"
android:background="#633ebe"
android:text="0"
android:textColor="#ffffff" />
<Button
android:id="@+id/btn3"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.4"
android:background="#1e7983"
android:text="0"
android:textColor="#ffffff" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/btn10"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.5"
android:background="#db552d"
android:text="0"
android:textColor="#ffffff" />
<Button
android:id="@+id/btn11"
android:layout_width="0dip"
android:layout_height="120dip"
android:layout_margin="2dip"
android:layout_weight="0.5"
android:background="#008e17"
android:text="0 "
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
+1
0
از ScrolView استفاده کن، فضاهایی که دادی بیش از حد معمول هست و از صفحه خارج می شه (11 سال پیش)
0
0
خیلی ممنون حل شد ، عرض دکمه ها متغییر هست آیا راهی هست که هم عرض و هم ارتفا دکمه ها متغییر بشه ؟ (11 سال پیش)
+1
0
معمولا یک بُعد ثابته، چرا که ما یک weight بیشتر نداریم. مگر در موارد خاصی که بخای عرض و طول یک view مثل دکمه، هم اندازه والدش بشه که اون والد کل فضای صفحه گوشی رو پر کرده، در اون حالت از match parent یا fill parent استفاده میکنی. (11 سال پیش)
0
0
ممنون از راهنماییت حسین (11 سال پیش)
برای این سوال 1 پاسخ وجود دارد.
پاسخ به سوال
Hossein Kurd
11 سال پیش
+1
0
مکن این قسمت رو توی UX انجام نمی دم
با این کد:
btn_test.setLayoutParams(new LinearLayout.LayoutParams(Width,Height));|
چون ارتفاع دیوایس ها به طول اونها نسبت ثابتی نداره اگر می خواهی درصد بدی سعی کن اول طول رو بگیری بعد تعیین کن طول دکمه 50% طول صفحه باشه و ارتفاعش برابر 10% طول
Width = (int) (screenWidth * 0.50 );
Height = (int) (screenWidth * 0.10 )
برای به دست آوردن طول و ارتفاع صفحه نمایش هم یه سرچ بزن توی انجمن گیرت می آد
درضمن برای wrap_content و ... هم می تونی از این استفاده کنی:
LinearLayout.LayoutParams.WRAP_CONTENT
اگر از RelativeLayout استفاده می کنی به جای LinearLayout بزن RelativeLayout
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .