5

image
I want to design the layout of this type of app(as shown in the image). In this layout when we click the circle icon it moves to next page. I want to know how its done.

Shahzad Barkati
  • 2,532
  • 6
  • 25
  • 33

3 Answers3

5

in drawer folder create circle_background.xml and put this code to it :

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="oval">
    <solid android:color="#FE4543"></solid>
     <stroke android:color="#FE4543" android:width="1dp"></stroke>

</shape>

so now in your activity add image view like this

<ImageView
        android:layout_width="wrap_content"
        android:gravity="center"
        android:layout_height="wrap_content"
        android:src="@drawable/ic_action_search"
        android:padding="15dp"
        android:id="@+id/btn_search"
        android:background="@drawable/circle_background"
        />

and if you want to add click action on this you have to use intent something like this , my view id is btn_search so at the first i have to find it like this and then set onclick listener for it like below

 ImageView btnSearch= (ImageView) findViewById(R.id.btn_search);
        btnSearch.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent= new Intent(getApplicationContext(),ExampleActivity.class)
                
            }
        });

dev.doc
  • 569
  • 3
  • 12
  • 18
Saeed Darvish
  • 621
  • 6
  • 29
0

The top one I think it can implement by ImageButton simplely.

Another one need a Layout with a circle background, and contain ImageView and TextView.

Hope it will be help for you.

chace
  • 1
  • 2
-1
public class TourActivity extends AppCompatActivity {
    private ImageView tour;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_tour);

        tour = (ImageView) findViewById(R.id.tour);
        tour.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent= new Intent(getApplicationContext(),FirstActivity.class);
                    launchThird();
            }
        });
    }

    private void launchThird() {

        Intent intent = new Intent(this, FirstActivity.class);
        startActivity(intent);
    }
}
Fabulous
  • 2,393
  • 2
  • 20
  • 27
Bwalya
  • 1
  • You will need to provide more to your answer than just code. Consider explaining what was wrong, or how you are fixing the original problem – Fabulous Apr 07 '18 at 14:01