布局底部的两个按钮在某些设备上不可见。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/framelayout1">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:id="@+id/viewpager1"
android:layout_height="match_parent"></android.support.v4.view.ViewPager>
<LinearLayout
android:la yout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<View
android:id="@+id/indicator1"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_margin="5dp"
android:background="@drawable/indicator_bg"></View>
<View
android:id="@+id/indicator2"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_margin="5dp"
android:background="@drawable/indicator_bg"></View>
<View
android:id="@+id/indicator3"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_margin="5dp"
android:background="@drawable/indicator_bg"></View>
<View
android:id="@+id/indicator4"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_margin="5dp"
android:background="@drawable/indicator_bg"></View>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#22000000"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/registerButton"
android:layout_weight="1"
android:background="#22000000"
android:textColor="@android:color/white"
android:text="REGISTER" />
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#cccc" />
<Button
android:layout_width="wrap_content"
android:background="#22000000"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@android:color/white"
android:id="@+id/signButton"
android:text="SIGN IN" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
使用此布局的FragmentActivity代码是
公共类WelcomePage扩展了FragmentActivity {
private Button signButton, registerButton;
private ViewPager pager;
private View indicator1, indicator2, indicator3, indicator4, indicator5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.welcome_main);
pager = (ViewPager) findViewById(R.id.viewpager1);
signButton = (Button) findViewById(R.id.signButton);
registerButton = (Button) findViewById(R.id.registerButton);
indicator1=(View)findViewById(R.id.indicator1);
indicator2=(View)findViewById(R.id.indicator2);
indicator3=(View)findViewById(R.id.indicator3);
indicator4=(View)findViewById(R.id.indicator4);
Typeface type1 = Typeface.createFromAsset(getAssets(), "fonts/Dosis/Dosis-Regular.ttf");
signButton.setTypeface(type1);
registerButton.setTypeface(type1);
MyPagerAdapter myAdapter = new MyPagerAdapter(getSupportFragmentManager());
pager.setAdapter(myAdapter);
update(0);
pager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
@Override
public void onPageScrolled(int i, float v, int i2) {
}
@Override
public void onPageSelected(int i) {
update(i);
}
@Override
public void onPageScrollStateChanged(int i) {
}
});
signButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(getApplicationContext(), Login.class);
startActivity(intent);
finish();
}
});
registerButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(WelcomePage.this, Signup.class));
finish();
}
});
}
MyPagerAdapter在哪里扩展FragmentPagerAdapter。有人建议调试这个吗?