0

アプリに紹介画面を追加したい。あるページから別のページにスライドする必要があります。3画面追加したいです。次のように画面のように:

下部に 3 つのドットがあります。それらを実装したい。また、次のページにスライドすると、色が変わり、中央のドットの位置が変わります。

このためのデフォルト構造を提供する1つのライブラリを見つけました。画面の下部にドットが表示され、左がスキップ、右が完了です。

https://github.com/PaoloRotolo/AppIntro .

これが私が探していたライブラリです。必要に応じてこれを実装できますか?

しかし、ここに示した画像のようなレイアウトが必要です。どうすればこれを達成できますか?

ここに画像の説明を入力

今、私はレイアウトを作成しました:

  <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/bg"
    android:weightSum="1">

    <ImageView
        android:layout_width="180dp"
        android:layout_height="50dp"
        android:id="@+id/imageView9"
        android:layout_gravity="center_horizontal"
        android:background="@drawable/logo_g"
        android:layout_marginTop="20dp"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" />

    <ImageView
        android:layout_width="200dp"
        android:layout_height="160dp"
        android:id="@+id/imageView10"
        android:layout_gravity="center"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/imageView9"
        android:layout_marginTop="30dp" />

    <TextView
        android:layout_width="220dp"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="@string/walkthrough1"
        android:id="@+id/textView3"
        android:layout_gravity="center_horizontal"
        android:layout_marginTop="10dp"
        android:textAlignment="center"
        android:textStyle="bold"
        android:layout_below="@+id/imageView10"
        android:layout_centerHorizontal="true"
        android:textColor="@android:color/black" />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:layout_marginTop="10dp"
        android:layout_marginBottom="10dp"
        android:layout_below="@+id/textView3"
        android:id="@+id/linearLayout8"
        android:layout_alignLeft="@+id/button2"
        android:layout_alignStart="@+id/button2"
        android:layout_alignRight="@+id/button2"
        android:layout_alignEnd="@+id/button2">

        <View
            android:layout_width="20dp"
            android:layout_height="20dp"
            android:background="@drawable/circle"></View>

    </LinearLayout>

    <Button
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="SIGN UP"
        android:id="@+id/button2"
        android:background="#66BB6A"
        android:textColor="@android:color/white"
        android:layout_below="@+id/linearLayout8"
        android:layout_centerHorizontal="true"
        android:layout_marginLeft="30dp"
        android:layout_marginRight="30dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="SKIP"
        android:id="@+id/textView4"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_marginBottom="10dp"
        android:textColor="@android:color/black" />

</RelativeLayout>

ドットの位置に 3 つの円ビューを追加し、次のページにスライドするときに色を変更することを考えました。しかし、このようなドット ビューを取得する方法と、ページからページにスライドする方法がわかりません。

誰でもこれを手伝ってもらえますか?ありがとうございました..

4

2 に答える 2

0

このコードを試してください: actvity_startup.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/gallery_paging"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 android:background="#000000"
 android:orientation="vertical" >
 <include layout="@layout/toolbar" />
 <Gallery
    android:id="@+id/mygallery01"
    android:layout_width="fill_parent"
    android:layout_below="@+id/my_awesome_toolbar"
    android:layout_height="fill_parent"/>
   <LinearLayout
    android:id="@+id/image_count"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:gravity="center" >
    </LinearLayout>
    <Button
    android:id="@+id/done"
    android:layout_width="250dp"
    android:layout_height="wrap_content"
    android:layout_above="@+id/image_count"
    android:layout_centerHorizontal="true"
    android:layout_marginBottom="18dp"
    android:background="#e74c3c"
    android:textColor="@color/white"
    android:textSize="25sp"
    android:textStyle="bold"
    android:text="Let's Start" />
</RelativeLayout>

StartUp.class:

package com.osomebuzz.meme_creator;

 import com.osomebuzz.meme_creator.adapter.IamgeAdapter;
 import android.content.Intent;
 import android.graphics.Typeface;
 import android.os.Bundle;
 import android.support.v7.app.AppCompatActivity;
  import android.support.v7.widget.Toolbar;
 import android.view.View;
 import android.view.View.OnClickListener;
 import android.widget.AdapterView;
 import android.widget.AdapterView.OnItemSelectedListener;
 import android.widget.Button;
 import android.widget.Gallery;
 import android.widget.LinearLayout;
 import android.widget.TextView;

 @SuppressWarnings("deprecation")
 public class StartUp extends AppCompatActivity {
 Gallery gallery;
    IamgeAdapter imageAdapter;
    LinearLayout count_layout;
    int count = 0;
    static TextView page_text[];
    TextView toolbartitle;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_startup);


    count_layout = (LinearLayout) findViewById(R.id.image_count);
    gallery = (Gallery) findViewById(R.id.mygallery01);
    Toolbar toolbar = (Toolbar) findViewById(R.id.my_awesome_toolbar);
    toolbartitle = (TextView) findViewById(R.id.titletool);
    toolbartitle.setText("Make Funny Photos");
    //getSupportActionBar().setTitle("Make Funny Photos");
    setSupportActionBar(toolbar);
    final Button done = (Button) findViewById(R.id.done);

    done.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Intent next = new Intent(getApplicationContext(),   

      MainActivity.class);
            startActivity(next);
            finish();
        }
    });
    imageAdapter = new IamgeAdapter(this);
    gallery.setAdapter(imageAdapter);
    count=gallery.getAdapter().getCount();
    page_text = new TextView[count];
    for (int i = 0; i < count; i++) {
        page_text[i] = new TextView(this);
        page_text[i].setText(".");
        page_text[i].setTextSize(45);
        page_text[i].setTypeface(null, Typeface.BOLD);
        page_text[i].setTextColor(android.graphics.Color.GRAY);
        count_layout.addView(page_text[i]);
    }
    gallery.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> arg0, View arg1,
                int position, long arg3) {
            // TODO Auto-generated method stub
            if(position == 0){
                done.setVisibility(View.INVISIBLE);

            }
            if(position == 1){
                done.setVisibility(View.INVISIBLE);

            }
            if(position == 2){
                done.setVisibility(View.INVISIBLE);

            }
            if(position == 3){
                done.setVisibility(View.INVISIBLE);

            }if(position == 4){
                done.setVisibility(View.VISIBLE);

            }
             for (int i = 0; i < count; i++) {


 StartUp.page_text[i].setTextColor(android.graphics.Color.GRAY);
                }


StartUp.page_text[position].setTextColor(android.graphics.Color.WHITE);

        }

        public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

        }
    });

     }

    }

ImageAdapter.class:

public class IamgeAdapter extends BaseAdapter {
private Context context;

public IamgeAdapter(Context c) {
// TODO Auto-generated constructor stub
this.context = c;
}
public int getCount() {
// TODO Auto-generated method stub
return flowers.length;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView image = new ImageView(context);
image.setImageResource(flowers[position]);
image.setScaleType(ScaleType.FIT_XY);
// image.setLayoutParams(new Gallery.LayoutParams(400, 400));
return image;
}
int[] flowers = { R.drawable.start1, R.drawable.start2, 

R.drawable.start3,R.drawable.start4,R.drawable.start5};

}
于 2016-05-06T11:07:56.747 に答える