我有一个水平滚动视图,我应该了解这个滚动视图的宽度。我已经尝试了我在网上找到的所有解决方案,但结果都是一样的:0。滚动视图:
<HorizontalScrollView
android:id="@+id/hsvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="@android:color/black"
android:scrollbars="none" >
<LinearLayout
android:id="@+id/lyt_bultens"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:scrollbars="horizontal" >
<TextView
android:id="@+id/tvBultenMain"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:text="Bülten bulunamadı."
android:textColor="@android:color/white"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:lines="2"
android:text="Bülten bulunamadı."
android:textColor="@android:color/white"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
</HorizontalScrollView>
我已经尝试过:
toDeltaX = hsv.getChildAt(0).getMeasuredWidth();
toDeltaX = hsv.getChildAt(0).getRight();
toDeltaX = hsv.getChildAt(0).getWidth();
toDeltaX = hsv.getMeasuredWidth();
toDeltaX = hsv.getRight();
toDeltaX = hsv.getWidth();
int index = lytBultens.getChildCount() - 1;
View view = lytBultens.getChildAt(index);
toDeltaX = view.getRight();
请帮忙。