I used an AutoCompleteTextView in my Service. after user type in AutoCompleteTextView, a drop down shown like this:
drop down is shown top of service layout but what I want is shown behind of that like this:
service use this layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<View
android:id="#+id/bg"
android:layout_width="64dp"
android:layout_height="64dp"
android:background="#drawable/floating_service_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<android.support.constraint.ConstraintLayout
android:id="#+id/collapse_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="#id/bg"
app:layout_constraintLeft_toLeftOf="#id/bg"
app:layout_constraintTop_toTopOf="#id/bg"
>
<ImageView
android:id="#+id/icon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_margin="8dp"
android:src="#drawable/star"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="#+id/close_btn"
android:layout_width="20dp"
android:layout_height="20dp"
android:background="#drawable/ic_close"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription"/>
</android.support.constraint.ConstraintLayout>
<View
android:id="#+id/drop_down_anchor"
android:layout_width="0dp"
android:layout_height="0.5dp"
android:layout_margin="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
/>
<LinearLayout
android:id="#+id/expanded_view"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="horizontal"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="#id/bg"
app:layout_constraintHorizontal_bias="0"
app:layout_constraintLeft_toRightOf="#id/collapse_view"
app:layout_constraintRight_toRightOf="#id/bg"
app:layout_constraintTop_toTopOf="#id/bg">
<AutoCompleteTextView
android:id="#+id/searchBox"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="#color/transparent"
android:dropDownAnchor="#id/drop_down_anchor"
android:gravity="left"
android:hint="#string/searchboxHint"
android:imeOptions="actionDone"
android:inputType="textPhonetic"
android:padding="15dip"
android:selectAllOnFocus="false"
android:singleLine="true"
android:textColor="#000"
android:textColorHint="#a5a5a5"
android:textIsSelectable="true"
android:textSize="16sp"
/>
<ImageView
android:id="#+id/search_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:src="#drawable/ic_search_24dp"
android:visibility="visible"
/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
and DropDownAdapter class:
class DropDownAdapter extends ArrayAdapter<String> {
ArrayList<String> wordList;
ArrayList<String> meanList;
public DropDownAdapter(ArrayList<String> words, ArrayList<String> means) {
super(context, R.layout.drop_down_layout, words);
this.wordList = words;
this.meanList = means;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(LAYOUT_INFLATER_SERVICE);
View rowView = (View) inflater.inflate(R.layout.drop_down_layout,
parent, false);
TextView leftTextView = (TextView) rowView.findViewById(R.id.item_word);
TextView rightTextView = (TextView) rowView.findViewById(R.id.item_mean);
LinearLayout dropDownItem = (LinearLayout) rowView.findViewById(R.id.drop_down_item);
final int pos = position;
leftTextView.setText(wordList.get(pos));
rightTextView.setText(meanList.get(pos));
return rowView;
}
}
can you suggest me a solution, please?
Related
I have 2 RecyclerViews that uses the same XML file to inflate views through the adapter.
One RecyclerView does catch clicks while the other doesn't.
The first RecyclerView is on another fragment and the code is similar to the second RecyclerView.
I have tried a lot of changes to the XML file(MaterialCardView) such as removing clickable attribute or changing the layout_weight to be 1 on the card but all of them didn't work.
Also, I can't understand why it would work only on 1 with the same settings on the other.
Here is the code for the second part which is not working:
Fragment - section of matter
list = view.findViewById(R.id.user_display_details_rv); //Getting the RecyclerView
list.setHasFixedSize(true);
int numOfColumns = 2;
list.setLayoutManager(new GridLayoutManager(getContext(), numOfColumns,GridLayoutManager.VERTICAL,false));
adapter = new UserDisplayDetailsAdapter(viewModel,getLayoutInflater());
list.setAdapter(adapter);
list.addItemDecoration(new RecyclerView.ItemDecoration() {
#Override
public void getItemOffsets(#NonNull Rect outRect, #NonNull View view, #NonNull RecyclerView parent, #NonNull RecyclerView.State state) {
outRect.set(5,20,5,20);
}
});
adapter.setOnItemClickListener((v,pos)->{
String pollId = Objects.requireNonNull(viewModel.getUserFilledPolls().get(pos).getPollId());
Navigation.findNavController(v).navigate(FragmentUserDisplayDetailsDirections.actionFragmentUserDisplayDetailsToFragmentOtherUserPoll(pollId,userId));
});
Adapter
public class UserDisplayDetailsAdapter extends RecyclerView.Adapter<UserDisplayDetailsHolder> {
UserDisplayDetailsViewModel viewModel;
LayoutInflater layoutInflater;
OnItemClickListener onItemClickListener;
public UserDisplayDetailsAdapter(UserDisplayDetailsViewModel viewModel, LayoutInflater layoutInflater) {
this.viewModel = viewModel;
this.layoutInflater = layoutInflater;
}
#NonNull
#Override
public UserDisplayDetailsHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
LayoutInflater inflater = (LayoutInflater) MyApplication.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.poll_list_square,parent,false);
return new UserDisplayDetailsHolder(view,onItemClickListener);
}
#Override
public void onBindViewHolder(#NonNull UserDisplayDetailsHolder holder, int position) {
Poll poll = Objects.requireNonNull(viewModel.getUserFilledPolls().get(position));
holder.bind(poll);
}
#Override
public int getItemCount() {
if(viewModel.getUserFilledPolls() == null){
return 0;
}
return viewModel.getUserFilledPolls().size();
}
public void setOnItemClickListener(OnItemClickListener listener){
this.onItemClickListener = listener;
}
}
Holder
public class UserDisplayDetailsHolder extends RecyclerView.ViewHolder {
MaterialTextView pollsName;
ShapeableImageView icon;
public UserDisplayDetailsHolder(#NonNull View itemView, OnItemClickListener onItemClickListener) {
super(itemView);
pollsName = itemView.findViewById(R.id.homescr_poll_pollName);
icon=itemView.findViewById(R.id.homescr_poll_icon);
itemView.setOnClickListener(v->{
int pos = getAdapterPosition();
onItemClickListener.onItemClick(v,pos);
});
}
public void bind(Poll poll) {
pollsName.setText(poll.getPollName());
}
}
Common XML
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
android:id="#+id/homescr_btn_poll"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:layout_width="110dp"
android:layout_height="90dp"
android:layout_gravity="center"
app:cardBackgroundColor="#color/primeOrng"
app:cardCornerRadius="20dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:strokeWidth="2dp"
android:theme="#style/Theme.MaterialComponents.Light">
<androidx.appcompat.widget.LinearLayoutCompat
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:orientation="horizontal">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homescr_poll_mainImage"
android:layout_width="60dp"
android:layout_height="40dp"
android:scaleType="fitStart"
app:strokeWidth="0dp"
app:srcCompat="#drawable/ic_poll" />
<Space
android:id="#+id/homescr_poll_space"
android:layout_width="10dp"
android:layout_height="wrap_content" />
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homescr_poll_icon"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_gravity="end"
app:srcCompat="#drawable/ic_feed_arrow"
app:strokeWidth="0dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom"
android:orientation="horizontal"
android:paddingLeft="8dp"
android:paddingRight="8dp">
<com.google.android.material.textview.MaterialTextView
android:id="#+id/homescr_poll_pollName"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="sans-serif-medium"
android:text="#string/poll_name"
android:textAppearance="?attr/textAppearanceHeadline6"
android:textColor="#color/white"
android:textSize="14dp"
android:textStyle="bold" />
</LinearLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homescr_poll_doneImage"
android:layout_width="60dp"
android:layout_height="50dp"
android:visibility="gone"
app:srcCompat="#drawable/done_nobg" />
</com.google.android.material.card.MaterialCardView>
Working Fragment XML(Catching clicks on RecyclerView)
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
app:cardElevation="0dp"
app:strokeColor="#color/stroke_color">
tools:context=".FragmentHomeScreen">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/homeScreen_logo"
android:layout_width="306dp"
android:layout_height="160dp"
android:src="#drawable/logo__nobg_2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/homeScr_text_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="50dp"
android:fontFamily="sans-serif-black"
android:gravity="center"
android:text="Hello, "
android:textColor="#color/white"
android:textSize="32dp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/homeScreen_logo" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/homeScr_text_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="80dp"
android:fontFamily="sans-serif-black"
android:gravity="start"
android:text="User Name"
android:maxLines="1"
android:textColor="#color/white"
android:textSize="32dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/homeScr_text_title"
app:layout_constraintTop_toBottomOf="#+id/homeScreen_logo" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/home_layout_const"
android:layout_width="350dp"
android:layout_height="250dp"
android:layout_marginStart="10dp"
android:layout_marginTop="30dp"
android:layout_marginEnd="10dp"
android:foregroundGravity="center_horizontal"
android:paddingLeft="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/homeScr_text_name">
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
android:id="#+id/home_layout_poll_refresh"
android:layout_width="wrap_content"
android:layout_height="match_parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/home_poll_rv"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:scrollbarSize="3dp"
android:scrollbarThumbVertical="#color/white"
android:scrollbars="vertical"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
/>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/homescr_btn_line"
android:layout_width="350dp"
android:layout_height="10dp"
android:layout_marginStart="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="90dp"
android:backgroundTint="#978F8F"
app:cornerRadius="100px"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<com.google.android.material.button.MaterialButton
android:id="#+id/homescr_btn_feed"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:backgroundTint="#color/black"
android:drawableTop="#drawable/ic_feed"
android:fontFamily="sans-serif-medium"
android:text="FEED"
android:textColor="#color/primeOrng"
android:textSize="14dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/homescr_btn_map"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/homescr_btn_line"
app:strokeColor="#color/black"
app:strokeWidth="2dp" />
<com.google.android.material.button.MaterialButton
android:id="#+id/homescr_btn_map"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:backgroundTint="#color/black"
android:drawableTop="#drawable/ic_map"
android:fontFamily="sans-serif-medium"
android:text="#string/map"
android:textColor="#color/primeOrng"
android:textSize="14dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="#+id/homescr_btn_feed"
app:layout_constraintTop_toBottomOf="#+id/homescr_btn_line"
app:strokeColor="#color/black"
app:strokeWidth="2dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
NOT Working Fragment XML(NOT Catching clicks on RecyclerView)
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black"
android:scrollbars="vertical"
android:scrollbarSize="3dp"
android:scrollbarStyle="insideInset"
tools:context=".feed.FragmentUserDisplayDetails">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp">
<com.google.android.material.imageview.ShapeableImageView
android:id="#+id/user_display_details_img_main"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_marginStart="8dp"
android:layout_marginTop="15dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:shapeAppearanceOverlay="#style/ShapeAppearanceOverlay.App.CornerSize50Percent"
app:srcCompat="#drawable/avatar"
app:strokeColor="#color/white"
app:strokeWidth="1dp" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_username"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:fontFamily="sans-serif-black"
android:gravity="center"
android:text="User Name"
android:textColor="#color/white"
android:textSize="32dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/user_display_details_img_main" />
<androidx.appcompat.widget.LinearLayoutCompat
android:id="#+id/user_dusplay_details_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="20dp"
android:orientation="vertical"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/user_display_details_txt_username">
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:drawableStart="#drawable/ic_account"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="20dp"
android:text="#string/email"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_address"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:drawableStart="#drawable/ic_white_location"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:maxLines="2"
android:paddingLeft="20dp"
android:text="address"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_education"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:drawableStart="#drawable/ic_education"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="20dp"
android:text="education"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<com.google.android.material.textview.MaterialTextView
android:id="#+id/user_display_details_txt_gender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:drawableStart="#drawable/sex_icon"
android:drawablePadding="10dp"
android:fontFamily="sans-serif-light"
android:gravity="left"
android:paddingLeft="20dp"
android:text="SEX"
android:textColor="#color/white"
android:textSize="28dp"
android:textStyle="bold" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/user_display_details_poll_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="#drawable/textviewbg">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/user_display_details_rv"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.appcompat.widget.LinearLayoutCompat>
<com.google.android.material.button.MaterialButton
android:id="#+id/feed_back_btn"
style="#style/Widget.MaterialComponents.Button.TextButton"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_marginStart="20dp"
android:layout_marginTop="30dp"
android:backgroundTint="#color/black"
android:fontFamily="sans-serif"
android:text="BACK "
android:textSize="20sp"
app:cornerRadius="35dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/user_dusplay_details_layout"
app:strokeColor="#color/primeOrng"
app:strokeWidth="1dp" />
<ProgressBar
android:id="#+id/user_display_details_progress_bar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
I try to dynamically populate a list and I have been following this question but for a reason my items aren't one under each other but one next to each others.
This is how I populate it using java:
public View onCreateView(#NonNull final LayoutInflater inflater,
final ViewGroup container, Bundle savedInstanceState) {
root = inflater.inflate(R.layout.fragment_detail_apero, container, false);
TextView name = (TextView)root.findViewById(R.id.name_apero);
name.setText(detailApero.getName());
TextView date = (TextView)root.findViewById(R.id.date_apero);
date.setText(detailApero.getDate());
LinearLayout ll = (LinearLayout)root.findViewById(R.id.vertical_layout_ingredient);
LinearLayout a = new LinearLayout(root.getContext());
a.setOrientation(LinearLayout.HORIZONTAL);
for(int i = 0; i < 20; i++)
{
Button b = new Button(root.getContext());
b.setText("Button "+i);
a.addView(b);
}
ll.addView(a);
and finally the xml structure:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimary"
tools:context=".ui.home.AperoDetailFragment">
<TextView
android:id="#+id/name_apero"
android:layout_width="156dp"
android:layout_height="53dp"
android:textSize="18sp"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/date_apero"
android:layout_width="238dp"
android:layout_height="53dp"
android:textSize="18sp"
android:ems="10"
android:gravity="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.907"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
<ScrollView
android:id="#+id/ingredient_apero"
android:layout_width="409dp"
android:layout_height="426dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.111"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.399">
<LinearLayout
android:id="#+id/vertical_layout_ingredient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center_vertical"
/>
</ScrollView>
<TextView
android:id="#+id/ingredient_title_apero"
android:layout_width="115dp"
android:layout_height="28dp"
android:text="Liste d'achat:"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.005"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.125" />
</androidx.constraintlayout.widget.ConstraintLayout>
I don't understand why they aren't coming one under each other, how can I do that ?
I have a recyclerview that inflates data fetched from json.
The issue I am facing are design issues - sometimes the text is aligned correctly and the image is shown and sometimes the text is too long, causing what I think is for the image not to be shown.
here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="395dp"
android:layout_height="170dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:background="#335634"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/heroImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:src="#mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/heroTitle"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:autoSizeMaxTextSize="25dp"
android:autoSizeMinTextSize="15dp"
android:text="Hero Title"
android:textSize="25dp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/heroDescription"
android:layout_width="200dp"
android:breakStrategy="simple"
android:layout_height="wrap_content"
android:layout_marginStart="36dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:autoSizeMaxTextSize="25dp"
android:autoSizeMinTextSize="15dp"
android:text="TextView"
android:textAlignment="center"
android:textSize="18dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/heroImage"
app:layout_constraintTop_toBottomOf="#+id/heroTitle" />
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
and here is my adapter:
public class HeroesAdapter extends RecyclerView.Adapter<HeroesAdapter.HeroesViewHolder> {
private List<Hero> heroList;
public HeroesAdapter(List<Hero> heroList) {
this.heroList = heroList;
}
#NonNull
#Override
public HeroesViewHolder onCreateViewHolder(#NonNull ViewGroup parent, int viewType) {
View rowView = LayoutInflater.from(parent.getContext()).inflate(R.layout.hero_cell, parent, false);
return new HeroesViewHolder(rowView);
}
#Override
public void onBindViewHolder(#NonNull HeroesViewHolder holder, int position) {
Hero currentHero = heroList.get(position);
String str = String.join(",", currentHero.abilities);
holder.heroTitle.setText(currentHero.title);
holder.heroAbilties.setText(str);
Picasso.get().load(currentHero.image).resize(500,500).into(holder.heroesImage);
}
#Override
public int getItemCount() {
return heroList.size();
}
public static class HeroesViewHolder extends RecyclerView.ViewHolder {
ImageView heroesImage;
TextView heroTitle;
TextView heroAbilties;
public HeroesViewHolder(#NonNull View itemView) {
super(itemView);
heroesImage = itemView.findViewById(R.id.heroImage);
heroTitle = itemView.findViewById(R.id.heroTitle);
heroAbilties = itemView.findViewById(R.id.heroDescription);
}
}
}
This is the result I am getting and this is the wanted result.
the issues I am facing are:
making each row have a clean design and act the same for all.
images are sometimes shown, sometimes not.
bottom view is "half in screen" and half out of screen.
By using LinearLayout you can design your hero_cell that will give you the desirable output. as I do it for now.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="horizontal"
android:padding="10dp"
android:background="#335634"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/heroImage"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:src="#drawable/logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:background="#335634"
android:layout_marginLeft="20dp"
android:orientation="vertical"
android:layout_gravity="center_vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/heroTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoSizeMaxTextSize="25dp"
android:autoSizeMinTextSize="15dp"
android:text="Hero Title"
android:textSize="25dp"
android:textStyle="bold"
/>
<TextView
android:id="#+id/heroDescription"
android:layout_width="match_parent"
android:breakStrategy="simple"
android:layout_height="wrap_content"
android:autoSizeMaxTextSize="25dp"
android:autoSizeMinTextSize="15dp"
android:text="TextView"
android:textSize="18dp" />
</LinearLayout>
According to your expectation, you should use card-view and I've updated the layout. Please check
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_margin="10dp"
app:cardCornerRadius="10dp"
android:elevation="10dp"
android:layout_height="wrap_content">
<android.support.constraint.ConstraintLayout
android:layout_width="395dp"
android:layout_height="170dp"
android:background="#fff"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/heroImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:src="#mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/heroTitle"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:autoSizeMaxTextSize="25dp"
android:autoSizeMinTextSize="15dp"
android:text="Hero Title"
android:textColor="#000"
android:textSize="25dp"
android:textStyle="bold"
app:layout_constraintBottom_toTopOf="#+id/heroDescription"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/heroImage"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/heroDescription"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:autoSizeMaxTextSize="25dp"
android:autoSizeMinTextSize="15dp"
android:breakStrategy="simple"
android:text="TextView"
android:textColor="#444"
android:textSize="18dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="#+id/heroImage"
app:layout_constraintTop_toBottomOf="#+id/heroTitle" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
I'm using a NestedScrollView in a CardView that's generated in a RecyclerView. I can't get the scrolling to work - there seems to be sporadic moments when I can scroll through the list in the top item but no other scrolls seem to work. Cheers!
This is the layout of the cardView that's generated in the RecyclerView:
<?xml version="1.0" encoding="utf-8"?
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/checkout_relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/merchantPurchase"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:layout_marginLeft="12dp"
android:layout_marginTop="4dp"
android:text="TextView"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="#+id/checkoutCard"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0"
android:layout_marginStart="12dp" />
<android.support.v7.widget.CardView
android:id="#+id/checkoutCard"
android:layout_width="340dp"
android:layout_height="90dp"
android:layout_margin="5dp"
android:layout_marginBottom="11dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:elevation="5dp"
app:cardCornerRadius="5dp"
app:contentPadding="5dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_goneMarginLeft="5dp"
app:layout_goneMarginRight="5dp">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingRight="5dp">
<TextView
android:id="#+id/textCentre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:text="Test2"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.7"
app:layout_constraintLeft_toLeftOf="#+id/extraContainer"
app:layout_constraintRight_toRightOf="#+id/extraContainer" />
<TextView
android:id="#+id/textRight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="2dp"
android:text="Test3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.533"
app:layout_constraintLeft_toLeftOf="#+id/otherContainer"
app:layout_constraintRight_toRightOf="#+id/otherContainer" />
<TextView
android:id="#+id/textLeft"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="1dp"
android:text="Test1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.444"
app:layout_constraintLeft_toLeftOf="#+id/priceContainer"
app:layout_constraintRight_toRightOf="#+id/priceContainer" />
<TextView
android:id="#+id/extraContainer"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:clickable="true"
android:scaleType="centerCrop"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/priceContainer"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.17" />
<TextView
android:id="#+id/priceContainer"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:clickable="true"
android:scaleType="centerCrop"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/itemTitle"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.17" />
<TextView
android:id="#+id/otherContainer"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:adjustViewBounds="true"
android:clickable="true"
android:scaleType="centerCrop"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/extraContainer"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.17" />
<TextView
android:id="#+id/itemTitle"
android:layout_width="71dp"
android:layout_height="39dp"
android:layout_marginLeft="4dp"
android:layout_marginStart="4dp"
android:text="TextView"
android:textAlignment="center"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.512" />
<LinearLayout
android:layout_width="63dp"
android:layout_height="53dp"
android:layout_marginLeft="0dp"
android:orientation="vertical"
app:layout_constraintLeft_toRightOf="#+id/otherContainer"
tools:layout_editor_absoluteY="19dp"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
tools:layout_editor_absoluteX="258dp">
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_gravity="fill_vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView45"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="#+id/textView44"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="#+id/textView43"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.CardView>
Then, my abridged code for MainActivity:
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.checkout_home);
cardPurchasesDataSet = new ArrayList<>();
for (int i = 0; i < productsForPurchase.length; i++) {
cardPurchasesDataSet.add(productsForPurchase[i]);
}
card_totalPrice = new ArrayList<>();
for (int i = 0; i < totalPriceData.length; i++) {
card_totalPrice.add(totalPriceData[i]);
}
card_extras = new ArrayList<>();
for (int i = 0; i < extrasData.length; i++) {
card_extras.add(extrasData[i]);
}
card_more = new ArrayList<>();
for (int i = 0; i < moreData.length; i++) {
card_more.add(moreData[i]);
}
merchants = new ArrayList<>();
for (int i = 0; i < merchantsData.length; i++) {
merchants.add(merchantsData[i]);
}
card_recyclerView = (RecyclerView) findViewById(R.id.recyclerView);
card_layoutManger = new LinearLayoutManager(this);
card_recyclerView.setLayoutManager(card_layoutManger);
card_adapter = new checkout_card_Adapter(cardPurchasesDataSet, card_totalPrice, card_extras, card_more, merchants);
card_recyclerView.setAdapter(card_adapter);
}
UPDATE 01: Added mainActivity layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="368dp"
android:layout_height="551dp"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
app:layout_constraintLeft_toLeftOf="parent"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:overScrollMode="never"
android:layout_marginBottom="8dp" />
Adapter
public class Checkout_Card_Adapter extends
RecyclerView.Adapter<Checkout_Card_Adapter.ViewHolder>{
private ArrayList<String> titleOfPurchase;
private ArrayList<String> priceOfPurchase;
private ArrayList<String> extrasOfPurchase;
private ArrayList<String> moreOfPurchase;
private ArrayList<String> merchantOfPurchase;
public Checkout_Card_Adapter(ArrayList<String> titleOfPurchase, ArrayList<String> priceOfPurchase, ArrayList<String> extrasOfPurchase, ArrayList<String> moreOfPurchase, ArrayList<String> merchantOfPurchase) {
this.titleOfPurchase = titleOfPurchase;
this.priceOfPurchase = priceOfPurchase;
this.extrasOfPurchase = extrasOfPurchase;
this.moreOfPurchase = moreOfPurchase;
this.merchantOfPurchase = merchantOfPurchase;
}
public interface VenueAdapterInterface {
void onVenueButtonClick(int position);
}
#Override
public Checkout_Card_Adapter.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int i) {
View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.checkout_scrollable_card, viewGroup, false);
Checkout_Card_Adapter.ViewHolder viewHolder = new Checkout_Card_Adapter.ViewHolder(v);
return viewHolder;
}
#Override
public void onBindViewHolder(Checkout_Card_Adapter.ViewHolder viewHolder, final int position) {
viewHolder.itemTitle.setText(titleOfPurchase.get(position));
viewHolder.itemPrice.setText(priceOfPurchase.get(position));
viewHolder.itemExtras.setText(extrasOfPurchase.get(position));
viewHolder.itemMore.setText(moreOfPurchase.get(position));
viewHolder.merchant.setText(merchantOfPurchase.get(position));
}
#Override
public int getItemCount() {
return titleOfPurchase.size();
}
public class ViewHolder extends RecyclerView.ViewHolder {
public ImageButton itemImage;
public TextView itemTitle;
public TextView itemPrice;
public TextView itemExtras;
public TextView itemMore;
public TextView merchant;
public ViewHolder(final View itemView) {
super(itemView);
itemTitle = (TextView) itemView.findViewById(R.id.itemTitle);
itemPrice = (TextView) itemView.findViewById(R.id.priceContainer);
itemExtras = (TextView) itemView.findViewById(R.id.extraContainer);
itemMore = (TextView) itemView.findViewById(R.id.otherContainer);
merchant = (TextView) itemView.findViewById(R.id.merchantPurchase);
}
}
}
As per your screen shot how do you expect it to scroll the inner view while it showing all the views? it will only scroll on small devices where your all textview won't be able to display. Can you please post a proper screenshot of this view from app.
I have a simple Adapter but always get the same error
view tag isn't correct on view:null
On my Activity I'm initializing the adapter as follows:
binding = DataBindingUtil.setContentView(this, R.layout.activity_main);
OptionsAdapter adapter = new OptionsAdapter(Option.defaultOptions());
binding.listView.setAdapter(adapter);
Here's my adapter
public class OptionsAdapter extends BaseAdapter {
private ObservableArrayList<Option> list;
public OptionsAdapter(ObservableArrayList<Option> list) {
this.list = list;
}
#Override
public int getCount() {
return list.size();
}
#Override
public Option getItem(int position) {
return list.get(position);
}
#Override
public long getItemId(int position) {
return position;
}
#Override
public View getView(int position, View convertView, ViewGroup parent) {
ItemBinding binding;
if (convertView == null) {
binding = DataBindingUtil.inflate(LayoutInflater.from(parent.getContext()), R.layout.item_layout, null, false);
convertView = binding.getRoot();
convertView.setTag(binding);
} else {
binding = (ItemBinding) convertView.getTag();
}
return convertView;
}
}
Update
R.layout.activity_main
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<android.support.constraint.ConstraintLayout
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.bixlabs.takeachanceapp.MainActivity">
<View
android:id="#+id/background_profile"
android:layout_width="0dp"
android:layout_height="200dp"
android:background="#f7f8f9"
app:layout_constraintBottom_toTopOf="#+id/horizontal_top"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<android.support.constraint.Guideline
android:id="#+id/horizontal_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.4"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="204dp" />
<android.support.v7.widget.CardView
android:id="#+id/circle_container"
android:layout_width="119dp"
android:layout_height="119dp"
app:cardCornerRadius="60dp"
app:cardElevation="8dp"
app:cardPreventCornerOverlap="false"
app:layout_constraintBottom_toTopOf="#+id/greeting_text"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="packed">
<ImageView
android:id="#+id/profile_image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/profile_picture"
android:src="#drawable/placeholder_profile" />
</android.support.v7.widget.CardView>
<TextView
android:id="#+id/greeting_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_marginTop="24dp"
android:textColor="#4a90e2"
android:textSize="18sp"
app:layout_constraintBottom_toTopOf="#+id/horizontal_top"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/circle_container"
app:layout_constraintVertical_chainStyle="packed"
tools:text="Welcome Bob Forest!" />
<TextView
android:id="#+id/current_date_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/background_profile"
tools:text="November 22, 2016" />
<ListView
android:id="#+id/listView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/current_date_text"
tools:listitem="#layout/item_main_options" />
</android.support.constraint.ConstraintLayout>
</layout>
R.layout.item_layout
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="option"
type="com.rkmax.model.Option" />
</data>
<android.support.constraint.ConstraintLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/title_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="#{option.title}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/account_number_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:text="#{option.account}"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/title_text" />
<TextView
android:id="#+id/detail_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:text="#{option.detail}"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/balance_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="8dp"
android:text="#{option.balanceString}"
android:textColor="#4eaef7"
android:textSize="18sp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/detail_text" />
</android.support.constraint.ConstraintLayout>
</layout>