Tom*_*Tom 2 java xml android scrollview android-linearlayout
我的ScrollView遇到了令人沮丧的问题,这是我的层次结构:
ScrollView (Vertical)
LinearLayout (Vertical)
ImageView weight= 0.5
Whatever weight= 0.1
Whatever weight= 0.2
Whatever weight= 0.2
Run Code Online (Sandbox Code Playgroud)
如果我删除ScrollView(并让LinearLayout作为主要项目),则此方法可以与任何Image一起正常使用:该图像占用屏幕大小的50%,其余的视图则占满其余屏幕。
但是,当ScrollView在此处时,如果“我的图像”太高,则“ weight”参数将被完全忽略:该图像将执行其适合屏幕宽度的所有操作,然后显然太高,并占到50%以上屏幕。编辑:实际上,所有“重量”属性似乎都被忽略了:
我希望线性布局完全适合而不需要滚动。那可能吗 ?我试图更改某些图像选项(scaleType,adjustViewBounds),但是我没有想要的东西。
这是整个xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.5"
android:adjustViewBounds="true"
android:src="@drawable/testing" />
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:text="I'M A TEST" />
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:text="I'M A TEST" />
<Button
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.2"
android:text="I'M A TEST" />
</LinearLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
注意:我需要ScrollView,因为我使用的是PullToRefresh ScrollView
也许为时已晚,但是可以通过添加android:fillViewport="true"到您的问题中来解决您的问题ScrollView:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true" >
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2554 次 |
| 最近记录: |