片段内的scrollview不滚动 [英] scrollview inside a fragment is not scrolling
本文介绍了片段内的scrollview不滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是应用开发的新手.
我正在使用3个标签.在每个片段中,我要显示cardview(7-8张卡片)的列表.
i am using 3 tabs. in each fragment i want to display a list of cardview(7-8 cards).
我的第一个fragment.xml
my first fragment.xml
<ScrollView
android:layout_height="fill_parent"
android:layout_width="match_parent"
android:fillViewport="true"
xmlns:android="http://schemas.android.com/apk/res/android" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp"
android:background="@color/white">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/crt1"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="2dp"
card_view:cardCornerRadius="1dp"
android:clickable="true"
android:foreground="?attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp">
<ImageView
android:layout_width="85dp"
android:layout_height="85dp"
android:src="@drawable/c_3musketeers" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three Musketeers"
android:textSize="25sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rare | Air + Ground"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Three Musketeers"
android:textSize="25sp" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="300dp"
android:id="@+id/crt2"
card_view:cardUseCompatPadding="true"
card_view:cardElevation="2dp"
card_view:cardCornerRadius="1dp"
android:clickable="true"
android:foreground="?attr/selectableItemBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="3dp">
<ImageView
android:layout_width="85dp"
android:layout_height="85dp"
android:src="@drawable/c_archers" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Archers"
android:textSize="25sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Common | Air + Ground"
android:textSize="15sp" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
当我安装此ap时,它根本不会滚动.
when i install this ap it is not scrolling at all.
我的fragment.java文件
my fragment.java file
public class TroopsFragment extends Fragment {
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
final ScrollView scrollview1 = (ScrollView) inflater.inflate(R.layout.troops,
container, false);
CardView cvt1;
cvt1 = (CardView) scrollview1.findViewById(R.id.crt1);
cvt1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Toast.makeText(getActivity(), "tushar kalsara",
Toast.LENGTH_SHORT).show();
}
});
return scrollview1;
}}
推荐答案
在ScrollView中添加此属性
Add this property in ScrollView
android:isScrollContainer="false"
,然后将LinearLayout
设为
wrap_content
这篇关于片段内的scrollview不滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文