Android 滚动视图高度0,即使在填充父对象时也是如此
我有一个包含imageview和scrollview的线性布局。scrollview包含第二个linearlayout B 这样做的目的是在linearLayout B包含多个与scrollview高度完全匹配的视图时,使用一个固定的标题。将其视为一个选项卡视图,其中所有选项卡在滚动视图中彼此紧随其后Android 滚动视图高度0,即使在填充父对象时也是如此,android,scrollview,android-linearlayout,Android,Scrollview,Android Linearlayout,我有一个包含imageview和scrollview的线性布局。scrollview包含第二个linearlayout B 这样做的目的是在linearLayout B包含多个与scrollview高度完全匹配的视图时,使用一个固定的标题。将其视为一个选项卡视图,其中所有选项卡在滚动视图中彼此紧随其后 <?xml version="1.0" encoding="utf-8"?> <LinearLayout android:id="@+id/main_view" xmln
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/main_view"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:orientation="vertical">
<ImageView android:id="@+id/logoImg"
android:layout_width="fill_parent"
android:gravity="center"
android:src="@drawable/logo"
android:layout_height="wrap_content"/>
<ScrollView
android:id="@+id/scrollView"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="@+id/scrollLinear"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</ScrollView>
</LinearLayout>
我试图通过调用scrollView上的getHeight来实现这一点,然后将此高度设置为linearLayout B中的每个视图,但getHeight始终返回0。
有人知道实现这一点最简单的方法是什么吗?好吧,这个问题已经很老了,但我想试试:) 在ScrollView中不是缺少“fillViewport”吗
<ScrollView
android:id="@+id/scrollView"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
>
很抱歉,我不明白。。。您想要与垂直选项卡视图等效的视图吗?那为什么要使用滚动视图呢?嗯,我想要一个动画选项卡视图。如果单击某个选项卡,则通过将scrollview滚动到正确的位置来显示正确的选项卡。我觉得这个看起来不错。我知道我可以使用tabview实现相同的功能效果,但不能达到相同的视觉效果。