تخطيط Android لا يعمل بشكل صحيح
-
29-10-2019 - |
سؤال
أنا أستخدم ملف main.xml
لتصميم واجهة المستخدم في أندرويد.لا أعرف لماذا الأخير TextView
(بطاقة تعريف:وصف الصورة) لا يعمل.إذا قمت بحذف ImageView
العلامة، والأخيرة TextView
سوف تعمل مرة أخرى.هنا لقطة الشاشة الخاصة بي.الأول في عندما لا ImageView
العلامة، والثانية عندما يكون ImageView
كما ترون، عندما يكون هناك صورة، لا أستطيع رؤية الخط Image descriptor: a cartoon tiger
.هنا أنا main.xml
:
<?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" >
<TextView
android:id="@+id/imageTitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/test_image_title"/>
<TextView
android:id="@+id/imageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_image_date"/>
<ImageView
android:id="@+id/imageDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/test_contentDescription"
android:src="@drawable/test_image"/>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/imageDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_image_description"/>
</ScrollView>
</LinearLayout>
شكرا لمساعدتي :)
المحلول
أنت تقوم بإضافة عرض النص imageDescription الخاص بك أسفل عرض الصورة وهذا أيضًا يحتوي على عرض التمرير الخاص بك مع fill_parent وارتفاعه، بمجرد تجربة ذلك
<TextView
android:id="@+id/imageDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_image_date"/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/imageDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/test_image_description"/>
</ScrollView>
<ImageView
android:id="@+id/imageDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/test_contentDescription"
android:src="@drawable/test_image"/>
أعتقد أن الصورة كبيرة جدًا، إذا كان الأمر كذلك، فحاول التحديد layout:weight
المعلمة لكل من عرض الصورة والنص بنسبة مناسبة.
نصائح أخرى
حاول تغيير جزء XML الخاص بك
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
ل
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
لان خاصتك ScrollView
يحاول أن يكون كبيرًا مثلك LinearLayout
في الارتفاع.
لدي إجابة أخرى لسؤالي، أنشرها هنا لمن شاهد مشاركتي ويحتاج إلى المزيد من الإجابات.التي أستخدمها android:adjustViewBounds="true"
ملكية :)