1
我的任务是为Android创建一个简单的图书搜索应用程序作为实习项目。我几乎完成了这个任务,但是我在布局方面做得很糟糕。如果ISBN号码是10位数字,发布的日期和说明总是会飞到屏幕左侧并出现在屏幕之外,但只有13位数字的时候它才是完美的。仅供参考,我使用google books API。如果我可以发布图片,这将更清晰,但我的代表太低了。Android图书搜索应用搜索结果布局不适合屏幕有时
这里是我的代码:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ImageView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/img_cover"
android:layout_width="180dp"
android:layout_height="170dp"
android:src="@drawable/img_books_large"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/tvTitle"
android:text="Title"
android:layout_marginTop="20dp"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/img_cover"
android:layout_toEndOf="@+id/img_cover" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Author"
android:id="@+id/tvAuthor"
android:layout_marginTop="25dp"
android:layout_below="@+id/tvTitle"
android:layout_toRightOf="@+id/img_cover"
android:layout_toEndOf="@+id/img_cover" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_below="@+id/img_cover"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="ISBN"
android:id="@+id/tvISBN"
android:layout_below="@+id/img_cover"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Publish Date"
android:id="@+id/tvPublishYear"
android:layout_below="@+id/tvISBN"
android:layout_marginTop="40dp"
android:layout_marginLeft="-220dp"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tvDescription"
android:layout_marginTop="80dp"
android:layout_below="@+id/tvPublishYear"
android:layout_marginLeft="-270dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Description"
/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
在此先感谢