我想在水平滾動內顯示兩個視圖,如下圖所示。我想知道的可能的方式來實現這一點,因爲我已經實現了產量遠遠不能要求,因爲我們可以在屏幕上看到下面抓起: -需要在水平滾動視圖中一次顯示兩個項目
這裏是我的佈局的一部分,它描述我已經實現了視圖: -
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="@+id/imageGallery"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="3"/>
</HorizontalScrollView>
向上述視圖i,那麼創建了一個線性佈局具有垂直取向,並添加到它的ImageView的,並且如在下面的代碼段示出3文本視圖: -
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
private View getVerticalLinearLayout(Integer image){
LinearLayout verticalLayout = new LinearLayout(getContext());
verticalLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT,2.0f));
verticalLayout.setOrientation(LinearLayout.VERTICAL);
verticalLayout.setBackground(getResources().getDrawable(R.drawable.layout_border));
verticalLayout.addView(scaleImage((ImageView) getImageView(image)));
verticalLayout.addView(getTextView("Book Name",14,"#444444"));
verticalLayout.addView(getTextView("Author Name",12,"#444444"));
verticalLayout.addView(getTextView("Lender Name",12,"444444"));
return verticalLayout;
}
請說明您的問題並重新格式化您的問題。 – Shaishav
是否要將每個項目的寬度設置爲父寬度的一半,並自由滾動?或者你想滾動像交換頁面,其中每個頁面上的每個頁面是2個項目? – auval
該項目應該分成父母寬度的一半。 – saunlogan