当使用ViewPager?时,是否有可能同时显示两个页面?我不是在寻找边缘效果,而是在寻找两个完整的页面.
提前致谢.
在尝试了Gallery和Horizontal Scroll View之后,我发现View Pager做了我需要的东西,但遗漏了一件小事.View Pager每页可以有多个视图吗?
我知道View Pager每次刷卡只显示1个视图/页面.我想知道我是否可以限制我的视图宽度,所以我的第二个视图会显示出来?
例如:我有3个视图,我希望屏幕显示视图1和视图2的一部分,以便用户知道有更多内容,以便他们可以滑动到视图2.
|view 1|view 2|view 3|
|screen |
Run Code Online (Sandbox Code Playgroud) 我已经做好了 Gallery View
gallery = (Gallery) findViewById(R.id.gallery1);
MyAdapter adapter = new MyAdapter(this);
gallery.setAdapter(adapter);
gallery.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
Intent go = new Intent(Department2.this,
tablistclass_item.class);
if (!larg) {
go = new Intent(Department2.this, ListClass.class);
}
Bundle b = new Bundle();
b.putString("headername", nameofimage[position]);
b.putString("whichclass", "department");
go.putExtras(b);
startActivity(go);
}
});
}
Run Code Online (Sandbox Code Playgroud)
现在该怎么做page indicator的Gallery view
我目前正在开发小应用程序,在某些时候用户需要选择一个选项.我收到的规范说明了水平列表以及可供选择的选项.当它低于箭头指针时选择该选项 - 类似于命运之轮.
这是我到目前为止所做的:
我的活动
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
LinearLayout tl = (LinearLayout) findViewById(R.id.index);
for (int i = 0; i < 10; i++) {
TextView textview = new TextView(this);
textview.setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
textview.setText("Text " + i);
tl.addView(textview);
}
}
}
Run Code Online (Sandbox Code Playgroud)
我的布局:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world" />
... the rest of normal layout
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical" …Run Code Online (Sandbox Code Playgroud)