Tuesday, 12 September 2017

Small Layout in whats app style


step 1:
activity_main.xml
    <FrameLayout
android:layout_width="match_parent"        
android:layout_height="match_parent"        
android:orientation="horizontal"        
android:layout_weight="1.1">
        <ImageView            
android:id="@+id/image_gallary"            
android:layout_width="40dp"            
android:layout_height="40dp"            
android:layout_gravity="center"            
android:layout_marginLeft="10dp"            
android:background="@drawable/folder"/>
<LinearLayout    
android:layout_width="290dp"    
android:id="@+id/visible"    
android:orientation="horizontal"    
android:layout_gravity="bottom"    
android:layout_marginLeft="20dp"   
android:visibility="gone"    
android:gravity="center"    
android:background="@drawable/visible_style"    
android:layout_height="80dp">
    <View        
android:layout_width="10dp"        
android:layout_height="match_parent"/>
    <LinearLayout        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:orientation="vertical">

       <ImageView           
android:id="@+id/call"           
android:layout_width="40dp"           
android:layout_height="40dp"           
android:layout_weight="1"           
android:background="@drawable/galary"           />
    <TextView        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:textColor="@android:color/black"        
android:text="Gallary"        
android:layout_gravity="center"        
android:textSize="13dp"/></LinearLayout>
    <View        
android:layout_width="20dp"        
android:layout_height="match_parent"/>
<LinearLayout    
android:layout_width="wrap_content"    
android:layout_height="wrap_content"    
android:orientation="vertical">
       <ImageView           
android:id="@+id/music"           
android:layout_width="40dp"           
android:layout_height="40dp"           
android:layout_weight="1"           
android:background="@drawable/music"/>
    <TextView        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:textColor="@android:color/black"        
android:text="Music"        
android:textSize="13dp"        
android:layout_gravity="center"/>
</LinearLayout>
    <View        
android:layout_width="20dp"        
android:layout_height="match_parent"/>
    <LinearLayout        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:orientation="vertical">
        <ImageView            
android:id="@+id/document"            
android:layout_gravity="center"            
android:layout_width="40dp"            
android:layout_height="40dp"            
android:layout_weight="1"            
android:background="@drawable/document"            />
        <TextView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:textColor="@android:color/black"            
android:text="Document"            
android:layout_gravity="center"            
android:textSize="13dp"/></LinearLayout>
    <View        
android:layout_width="20dp"        
android:layout_height="match_parent"/>
    <LinearLayout        
android:layout_width="wrap_content"        
android:layout_height="wrap_content"        
android:orientation="vertical">
        <ImageView            
android:id="@+id/Locate"            
android:layout_width="40dp"            
android:layout_height="40dp"            
android:layout_weight="1"            
android:background="@drawable/locate"            />
        <TextView            
android:layout_width="wrap_content"            
android:layout_height="wrap_content"            
android:textColor="@android:color/black"            
android:text="Locate"            
android:layout_gravity="center"            
android:textSize="13dp"/>
    </LinearLayout>   </FrameLayout>
step 2:
MainActivity.java
public class MainActivity extends AppCompatActivity {
   
  int a;
    @Override    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_message);
     
    final ImageView imageView=(ImageView)findViewById(R.id.image_gallary);
      final LinearLayout l=(LinearLayout)findViewById(R.id.visible);
imageView.setOnClickListener(new View.OnClickListener() {

    @Override    public void onClick(View v) {
        if (a==1){
           l.setVisibility(View.VISIBLE);
            a--;
        }
        else {
            l.setVisibility(View.INVISIBLE);
            a++;
        }
    }
});

No comments:

Post a Comment

HOW TO CREATE CIRCLE IMAGE VIEW

Step 1: implementation 'de.hdodenhof:circleimageview:3.0.0' Step 2: <de.hdodenhof.circleimageview.CircleImageView xmlns:ap...