I am displaying text and images in a ListView with HorizontalScrollView if the text and images is too long for the screen size but I thought it would only be there if it is needed.
But even when there is no need for the HorizontalScrollView cause the text and images fit in screen it still appears for every row and it is all in tabs so this makes swiping from tab to tab irritating cause your finger catches the HorizontalScrollView and not the whole tab.
And all textviews ect... are in one layout file so I can't choose only certain rows.
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView1"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="30dp"
android:layout_height="30dp"/>
<TextView
android:id="@+id/textView2"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView2"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="30dp"
android:layout_height="30dp"/>
<TextView
android:id="@+id/textView3"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView3"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="30dp"
android:layout_height="30dp"/>
<TextView
android:id="@+id/textView4"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView4"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="30dp"
android:layout_height="30dp"/>
<TextView
android:id="@+id/textView5"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView5"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="30dp"
android:layout_height="30dp"/>
<TextView
android:id="@+id/textView6"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView6"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="30dp"
android:layout_height="30dp"/>
<TextView
android:id="@+id/textView7"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<ImageView
android:id="@+id/imageView7"
android:layout_marginStart="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_width="30dp"
android:layout_height="30dp"/>
</LinearLayout>
</HorizontalScrollView>
View v=infla.inflate(R.layout.main_tab_layout, null);
TextView tv1=(TextView)v.findViewById(R.id.textView1);
ImageView iv1=(ImageView)v.findViewById(R.id.imageView1);
TextView tv2=(TextView)v.findViewById(R.id.textView2);
ImageView iv2=(ImageView)v.findViewById(R.id.imageView2);
tv1.setText(text1[position]);
iv1.setImageResource(text2[position]);
tv2.setText(text3[position]);
iv2.setImageResource(text4[position]);
if(text3[position].matches("")) {
tv2.setVisibility(View.GONE);
}
if(text4[position]==R.drawable.ic_star){
iv2.setVisibility(View.GONE);
}
return v;
}