标签:android-layout android-imageview scrollview android-scrollview android
在下面的代码中,我有两个主要容器,一个RelativeLayout和一个ScrollView.我需要将RelativeLayout固定在最上面,并在下面使ScrollView和Images滚动.我有以下两个问题:
>尽管我的ScrollView是可滚动的,但它位于RelativeLayout的顶部. !重要
>垂直LinearLayout中存在的我的图像视图为缩略图大小.如果我有15-20张图像,则它们会占用很多垂直空间.如何根据屏幕尺寸使图像适合一行中的最大值,然后转到下一行?
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</RelativeLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView>
</ImageView>
<ImageView>
</ImageView>
<ImageView>
</ImageView>
<ImageView>
</ImageView>
</LinearLayout>
</ScrollView>
解决方法:
按照以下简单方法进行操作:
>您需要为父级使用固定的高度,即< RelativeLayout>.
>将ScrollView的高度设置为match_parent.
>确保将所有内容放入LinearLayout中.
最后,您将得到以下结果:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</RelativeLayout>
</LinearLayout>
标签:android-layout,android-imageview,scrollview,android-scrollview,android 来源: https://codeday.me/bug/20191028/1954024.html
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。