title: Expandable View in Android
body: <p>Hi I'm currently working on styling my user info form, Can i ask someone on how to achieve when i press a certain imageview button my view will expand and vice versa.</p>
  
  <p>Sample Screen shot: </p>
  
  <p>If not expanded.</p>
  
  <p><a href="https://i.stack.imgur.com/eDEgm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eDEgm.png" alt="enter image description here"></a></p>
  
  <p>When press the arrow down to expand:</p>
  
  <p><a href="https://i.stack.imgur.com/TuOEP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TuOEP.png" alt="enter image description here"></a></p>
  
  <p>MainActivity.java</p>
  
  <pre><code>import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.support.v7.widget.LinearLayoutManager;
  import android.support.v7.widget.RecyclerView;
  import android.support.v7.widget.Toolbar;
  
  import com.yoesuv.demorecyclerview.adapter.CardViewAdapter;
  
  public class MainActivity extends AppCompatActivity {
  
      private String[] dataset;
      private RecyclerView.Adapter adapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          dataset = getResources().getStringArray(R.array.android);
  
          Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
          setSupportActionBar(toolbar);
          if(getSupportActionBar()!=null){
              getSupportActionBar().setElevation(5);
          }
  
          RecyclerView mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
          mRecyclerView.setHasFixedSize(true);
          mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
  
          adapter = new CardViewAdapter(dataset);
          mRecyclerView.setAdapter(adapter);
      }
  }
  </code></pre>
  
  <p>CardviewAdapter.java</p>
  
  <pre><code>import android.support.v7.widget.RecyclerView;
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.TextView;
  import android.widget.Toast;
  
  import com.yoesuv.demorecyclerview.R;
  
  public class CardViewAdapter extends RecyclerView.Adapter&lt;CardViewAdapter.ViewHolder&gt; {
  
      private String[] dataset;
  
      public CardViewAdapter(String[] dataset){
          this.dataset = dataset;
      }
  
      @Override
      public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View itemLayout = LayoutInflater.from(parent.getContext()).inflate(R.layout.cardview_row, null);
          return new ViewHolder(itemLayout);
      }
  
      @Override
      public void onBindViewHolder(ViewHolder holder, int position) {
          holder.tV.setText(dataset[position]);
      }
  
      @Override
      public int getItemCount() {
          return dataset.length;
      }
  
      public static class ViewHolder extends RecyclerView.ViewHolder{
  
          public TextView tV;
  
          public ViewHolder(View itemView) {
              super(itemView);
  
              tV = (TextView) itemView.findViewById(R.id.textView_data);
              itemView.setOnClickListener(new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                      Toast.makeText(v.getContext(), tV.getText().toString(), Toast.LENGTH_SHORT).show();
                  }
              });
          }
      }
  }
  </code></pre>
  
  <p>Appreciate for any help.</p>