Space of bottom ListView - java

The problem is that I need to do so that the inside was ScrollView ListView, and he and scrollview scrolls. That's how I realized, but between the ListView and the third container large space.
main_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Details.Book.BookDetails"
android:background="#color/fragment_bg">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/scrollView6"
android:layout_below="#+id/toolbar">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/toolbar"
android:id="#+id/linearLayout16">
<RelativeLayout
android:id="#+id/relativeLayout9"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/rounded_top_layout"
android:paddingBottom="#dimen/leftPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingRight="#dimen/rightPadding"
android:paddingTop="#dimen/leftPadding">
<TextView
android:id="#+id/textviewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="false"
android:layout_centerVertical="true"
android:text="#string/buy_det_pass_txt"
android:textColor="#color/background_color"
android:textSize="#dimen/mainLargeSize" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout9"
android:paddingBottom="#dimen/leftPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingRight="#dimen/rightPadding"
android:paddingTop="#dimen/leftPadding">
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/relativeLayout9"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/textView43"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_fullname"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout4"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/textView35"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_gender"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvGender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout3"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/textView37"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_ticknumber"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvTickNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout6"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:id="#+id/textView39"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_issdate"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvIssDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<ListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listView"
android:layout_centerHorizontal="true"
android:paddingRight="#dimen/textMargin"
android:paddingLeft="#dimen/textMargin"
android:layout_below="#+id/linearLayout16" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/listView">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/rounded_top_layout"
android:id="#+id/relativeLayout9"
android:paddingTop="#dimen/leftPadding"
android:paddingBottom="#dimen/leftPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingRight="#dimen/rightPadding">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/buy_det_cost_txt"
android:id="#+id/tvFromTo"
android:textColor="#color/background_color"
android:textSize="#dimen/mainLargeSize"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout9"
android:id="#+id/relativeLayout10"
android:paddingRight="#dimen/rightPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingTop="#dimen/leftPadding"
android:paddingBottom="#dimen/leftPadding">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout4"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_fare"
android:id="#+id/textView43"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvFare"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout3"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_taxes"
android:id="#+id/textView35"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvTaxes"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout6"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_service_fees"
android:id="#+id/textView37"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvFees"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout6"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout7"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_total_price"
android:id="#+id/textView39"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvTotPrice"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout7"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout15"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_form_of_pay"
android:id="#+id/textView54"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvPayment"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
MainActivity.java
ListView listView = (ListView)findViewById(R.id.listView);
ListUtils.setDynamicHeight(listView);
ListUtils class
public static class ListUtils {
public static void setDynamicHeight(ListView mListView) {
ListAdapter mListAdapter = mListView.getAdapter();
if (mListAdapter == null) {
return;
}
int height = 0;
int desiredWidth = View.MeasureSpec.makeMeasureSpec(mListView.getWidth(), View.MeasureSpec.UNSPECIFIED);
for (int i = 0; i < mListAdapter.getCount(); i++) {
View listItem = mListAdapter.getView(i, null, mListView);
listItem.measure(desiredWidth, View.MeasureSpec.UNSPECIFIED);
height += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams params = mListView.getLayoutParams();
params.height = height + (mListView.getDividerHeight() * (mListAdapter.getCount() - 1));
mListView.setLayoutParams(params);
mListView.requestLayout();
}
}

Related

When one object is clicked, two listeners are fired

Good day!
I made two cards using **CardView**, then each of them has a **Title** and a **body**. The body should expand when you click on the title. But when you click on "*carsCollapse*", "*socketsCollapse*" also fires. This can be seen on the video. Also, for clarity, I made a Toast, so we can see that when you click on carsCollapse, "*Cars*" and "*Sockets*" appear.
Video: THE LINK
Here is the xml code (shortened version):
<?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="wrap_content"
android:orientation="vertical"
tools:context=".MapFilterFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
app:cardElevation="10dp"
app:contentPadding="20dp">
<LinearLayout
android:animateLayoutChanges="true"
android:id="#+id/carsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/carsCollapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:src="#drawable/ic_baseline_electric_car_24" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Cars"
android:textSize="26sp"
android:textStyle="bold"
android:textColor="#color/black"/>
</LinearLayout>
<LinearLayout
android:id="#+id/carsFilters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
// SOMETHING IN
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
app:cardElevation="10dp"
app:contentPadding="20dp">
<LinearLayout
android:animateLayoutChanges="true"
android:id="#+id/socketsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/socketsCollapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:src="#drawable/ic_baseline_electrical_services_24" />
<TextView
android:textColor="#color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Sockets"
android:textSize="26sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/socketsFilters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
// SOMETHING
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
Here is the java code:
package com.maxet24.chargely;
import android.animation.LayoutTransition;
import android.os.Bundle;
import androidx.fragment.app.Fragment;
import android.transition.AutoTransition;
import android.transition.TransitionManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
public class MapFilterFragment extends Fragment implements View.OnClickListener {
public LinearLayout carsFilters, socketsFilters, carsLayout, socketsLayout, carsCollapse, socketsCollapse;
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.fragment_map_filter, container, false);
// INIT
socketsLayout = v.findViewById(R.id.socketsLayout);
carsLayout = v.findViewById(R.id.carsLayout);
carsCollapse = v.findViewById(R.id.carsCollapse);
carsFilters = v.findViewById(R.id.carsFilters);
socketsCollapse = v.findViewById(R.id.socketsCollapse);
socketsFilters = v.findViewById(R.id.socketsFilters);
carsCollapse.setOnClickListener(this);
socketsCollapse.setOnClickListener(this);
carsLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
socketsLayout.getLayoutTransition().enableTransitionType(LayoutTransition.CHANGING);
// INIT
return v;
}
#Override
public void onClick(View view) {
switch (view.getId()) {
case R.id.carsCollapse:
Toast.makeText(getContext(), "Cars", Toast.LENGTH_SHORT).show();
toggleFilters(carsFilters, carsLayout);
case R.id.socketsCollapse:
Toast.makeText(getContext(), "Sockets", Toast.LENGTH_SHORT).show();
toggleFilters(socketsFilters, socketsLayout);
}
}
public void toggleFilters(LinearLayout filters, LinearLayout layout) {
TransitionManager.beginDelayedTransition(layout, new AutoTransition());
if (filters.getVisibility() == View.VISIBLE) {
filters.setVisibility(View.GONE);
} else{
filters.setVisibility(View.VISIBLE);
}
}
}
Full xml code (just in case):
<?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="wrap_content"
android:orientation="vertical"
tools:context=".MapFilterFragment">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
app:cardElevation="10dp"
app:contentPadding="20dp">
<LinearLayout
android:animateLayoutChanges="true"
android:id="#+id/carsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/carsCollapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:src="#drawable/ic_baseline_electric_car_24" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Cars"
android:textSize="26sp"
android:textStyle="bold"
android:textColor="#color/black"/>
</LinearLayout>
<LinearLayout
android:id="#+id/carsFilters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="visible">
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView5"
android:layout_height="50dp"
android:layout_width="50dp"
app:srcCompat="#drawable/ch_type_1" />
<TextView
android:layout_marginLeft="30dp"
android:id="#+id/textView6"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Type 1"
android:layout_marginTop="4dp"
android:textSize="24sp" />
<Switch
android:id="#+id/switch1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="6dp"
tools:ignore="UseSwitchCompatOrMaterialXml"
android:layout_marginBottom="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="7dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView8"
android:layout_height="50dp"
android:layout_width="50dp"
app:srcCompat="#drawable/ch_type_2" />
<TextView
android:layout_marginLeft="30dp"
android:id="#+id/textView9"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="Type 2"
android:layout_marginTop="4dp"
android:textSize="24sp" />
<Switch
android:id="#+id/switch2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="6dp"
tools:ignore="UseSwitchCompatOrMaterialXml"
android:layout_marginBottom="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="7dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView7"
android:layout_height="50dp"
android:layout_width="50dp"
app:srcCompat="#drawable/ch_type_3" />
<TextView
android:textAlignment="center"
android:layout_marginLeft="30dp"
android:id="#+id/textView8"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="CHAdeMO"
android:layout_marginTop="4dp"
android:textSize="24sp" />
<Switch
android:id="#+id/switch3"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="6dp"
tools:ignore="UseSwitchCompatOrMaterialXml"
android:layout_marginBottom="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="7dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView9"
android:layout_height="50dp"
android:layout_width="50dp"
app:srcCompat="#drawable/ch_type_4" />
<TextView
android:layout_marginLeft="30dp"
android:id="#+id/textView10"
android:layout_width="110dp"
android:layout_height="70dp"
android:layout_weight="1"
android:text="CCS combo type 1"
android:layout_marginTop="4dp"
android:textSize="24sp" />
<Switch
android:id="#+id/switch4"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="6dp"
tools:ignore="UseSwitchCompatOrMaterialXml"
android:layout_marginBottom="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_marginTop="7dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView10"
android:layout_height="50dp"
android:layout_width="50dp"
app:srcCompat="#drawable/ch_type_5" />
<TextView
android:layout_marginLeft="30dp"
android:id="#+id/textView11"
android:layout_width="110dp"
android:layout_height="70dp"
android:layout_weight="1"
android:text="CCS combo type 2"
android:layout_marginTop="4dp"
android:textSize="24sp" />
<Switch
android:id="#+id/switch5"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginTop="6dp"
tools:ignore="UseSwitchCompatOrMaterialXml"
android:layout_marginBottom="10dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginBottom="10dp"
app:cardElevation="10dp"
app:contentPadding="20dp">
<LinearLayout
android:animateLayoutChanges="true"
android:id="#+id/socketsLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/socketsCollapse"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:layout_width="36dp"
android:layout_height="36dp"
android:src="#drawable/ic_baseline_electrical_services_24" />
<TextView
android:textColor="#color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:text="Sockets"
android:textSize="26sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/socketsFilters"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/example"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</ScrollView>
Thanks for any help!

Align elements in Linear Layout

I'm trying to recreate this layout I made with the
RelativeLayout but I'm having a lot of troubles:
I divided the new LinearLayout into two sub-LinearLayout. In the first one I would place the Image and the description on the left, and the table with the text on the right. In the second LinearLayout I would put the last table and description. This is what it looks like by doing this:
This is the code, I really don't understand what's wrong:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/slidelinearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background_main2"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="640dp"
android:layout_height="438dp"
android:layout_gravity="left"
android:layout_weight="0.01"
android:gravity="left"
android:orientation="vertical">
<ImageView
android:id="#+id/slideimg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="124dp"
android:layout_marginTop="144dp"
tools:layout_conversion_absoluteHeight="380dp"
tools:layout_conversion_absoluteWidth="420dp"
tools:layout_editor_absoluteX="220dp"
tools:layout_editor_absoluteY="120dp" />
<TextView
android:id="#+id/txttitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/slideimg"
android:layout_alignEnd="#+id/slideimg"
android:padding="16dp"
android:text="Title Here"
android:textColor="#000000"
android:textSize="30sp"
android:textStyle="bold"
tools:layout_conversion_absoluteHeight="73dp"
tools:layout_conversion_absoluteWidth="166dp"
tools:layout_editor_absoluteX="330dp"
tools:layout_editor_absoluteY="480dp" />
<TextView
android:id="#+id/t1"
android:layout_width="249dp"
android:layout_height="79dp"
android:layout_above="#+id/tl"
android:layout_alignEnd="#+id/tl"
android:layout_marginEnd="13dp"
android:layout_marginBottom="-32dp"
android:fontFamily="#font/sriracha"
android:text="Punteggio finale"
android:textColor="#DD1717"
android:textSize="30dp"
tools:layout_conversion_absoluteHeight="61dp"
tools:layout_conversion_absoluteWidth="217dp"
tools:layout_editor_absoluteX="760dp"
tools:layout_editor_absoluteY="150dp" />
<TextView
android:id="#+id/t"
android:layout_width="wrap_content"
android:layout_height="57dp"
android:layout_alignTop="#+id/t1"
android:layout_alignEnd="#+id/t1"
android:layout_marginTop="5dp"
android:layout_marginEnd="33dp"
android:fontFamily="#font/sriracha"
android:text="______________"
android:textColor="#020101"
android:textSize="30dp"
tools:layout_conversion_absoluteHeight="61dp"
tools:layout_conversion_absoluteWidth="210dp"
tools:layout_editor_absoluteX="765dp"
tools:layout_editor_absoluteY="153dp" />
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/tl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/t2"
android:layout_alignParentEnd="true"
android:layout_marginEnd="265dp"
android:layout_marginBottom="86dp"
android:background="#android:color/white"
android:padding="18dp"
tools:context=".Result"
tools:layout_conversion_absoluteHeight="260dp"
tools:layout_conversion_absoluteWidth="316dp"
tools:layout_editor_absoluteX="220dp"
tools:layout_editor_absoluteY="190dp">
<TableRow
android:id="#+id/tr_item_1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/item_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Flessibilità"
android:textColor="#030101"
android:textSize="30dp" />
<TextView
android:id="#+id/f_item_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
<TableRow
android:id="#+id/tr_item_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/item_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Fluidità"
android:textColor="#070404"
android:textSize="30dp" />
<TextView
android:id="#+id/fl_item_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
<TableRow
android:id="#+id/tr_item_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/item_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Originalità"
android:textColor="#070404"
android:textSize="30dp" />
<TextView
android:id="#+id/o_item_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
<TableRow
android:id="#+id/tr_item_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/item_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Elaborazione"
android:textColor="#070404"
android:textSize="30dp" />
<TextView
android:id="#+id/el_item_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
<TableRow
android:id="#+id/tr_item_5"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/item_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Titolo"
android:textColor="#070404"
android:textSize="30dp" />
<TextView
android:id="#+id/t_item_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
</TableLayout>
</LinearLayout>
<LinearLayout
android:layout_width="408dp"
android:layout_height="279dp">
<TextView
android:id="#+id/t4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/tl_2"
android:layout_alignBottom="#+id/t1"
android:layout_gravity="right"
android:layout_marginEnd="-1dp"
android:layout_marginBottom="-478dp"
android:fontFamily="#font/sriracha"
android:gravity="right"
android:text="______________________"
android:textColor="#020101"
android:textSize="30dp"
tools:layout_conversion_absoluteHeight="115dp"
tools:layout_conversion_absoluteWidth="239dp"
tools:layout_editor_absoluteX="785dp"
tools:layout_editor_absoluteY="532dp" />
<TableLayout
android:id="#+id/tl_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="#+id/tl"
android:layout_alignParentBottom="true"
android:layout_marginTop="193dp"
android:layout_marginEnd="-248dp"
android:layout_marginBottom="26dp"
android:background="#android:color/white"
android:padding="25dp"
tools:context=".Result"
tools:layout_conversion_absoluteHeight="208dp"
tools:layout_conversion_absoluteWidth="314dp"
tools:layout_editor_absoluteX="710dp"
tools:layout_editor_absoluteY="560dp">
<TableRow
android:id="#+id/tr_item_6"
android:layout_width="222dp"
android:layout_height="match_parent"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/t1_item_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Tempo di reazione"
android:textColor="#070404"
android:textSize="30dp" />
<TextView
android:id="#+id/tempo_item_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
<TableRow
android:id="#+id/tr_item_7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/t2_item_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Tempo di completamento"
android:textColor="#070404"
android:textSize="30dp" />
<TextView
android:id="#+id/tempo_item_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
<TableRow
android:id="#+id/tr_item_8"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/table_row_bg"
android:padding="2dp">
<TextView
android:id="#+id/n_cancellature"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingRight="10dp"
android:text=" Numero cancellature"
android:textColor="#070404"
android:textSize="30dp" />
<TextView
android:id="#+id/n_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/table_cell_bg"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:textColor="#070404"
android:textSize="30dp" />
</TableRow>
</TableLayout>
<TextView
android:id="#+id/t2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/tl_2"
android:layout_marginEnd="-408dp"
android:layout_marginBottom="166dp"
android:layout_toStartOf="#+id/tl_2"
android:fontFamily="#font/sriracha"
android:text="Considerazioni aggiuntive"
android:textColor="#DD1717"
android:textSize="30dp"
tools:layout_conversion_absoluteHeight="115dp"
tools:layout_conversion_absoluteWidth="244dp"
tools:layout_editor_absoluteX="780dp"
tools:layout_editor_absoluteY="530dp" />
</LinearLayout>
Create the two separate layouts for the tables and include it in the main layout as follows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/bg">
<LinearLayout
android:id="#+id/upperLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="160dp"
android:layout_marginTop="140dp"
android:orientation="vertical">
<ImageView
android:layout_width="400dp"
android:layout_height="350dp"
android:layout_marginRight="150dp"
android:background="#android:color/darker_gray"
android:src="#drawable/ic_launcher_link" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="60dp"
android:layout_marginTop="20dp"
android:text="Senza nome"
android:textColor="#android:color/black"
android:textSize="40sp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/upperTableHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="160dp"
android:text="Table Header here"
android:textColor="#android:color/holo_red_light"
android:textSize="30sp" />
<include layout="#layout/upper_table"></include>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/upperLayout"
android:layout_alignParentRight="true"
android:layout_marginTop="30dp"
android:layout_marginRight="80dp"
android:orientation="vertical">
<TextView
android:id="#+id/lowerTableHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Table Header here"
android:textColor="#android:color/holo_red_light"
android:textSize="30sp" />
<include layout="#layout/lower_table"></include>
</LinearLayout>
</RelativeLayout>
add the following methods to your Activity class:
public int getWidth() {
DisplayMetrics displayMetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
int width = displayMetrics.widthPixels;
return width;
}
public void setLayoutMargins() {
View layout = findViewById(R.id.relative);
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(layout.getLayoutParams());
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
layoutParams.topMargin = 400;
layout.setLayoutParams(layoutParams);
//ImageView Layout
View image = findViewById(R.id.imgage);
LinearLayout.LayoutParams imageParams = new LinearLayout.LayoutParams(image.getLayoutParams());
image.getLayoutParams();
imageParams.width = 800;
imageParams.height = 600;
image.setBackgroundColor(getResources().getColor(android.R.color.holo_green_dark));
image.setLayoutParams(imageParams);
//UpperTable Layout
View upperTable = findViewById(R.id.upperTableLayout);
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(upperTable.getLayoutParams());
params.leftMargin = 250;
params.topMargin = 160;
upperTable.setLayoutParams(params);
}
public void setTextSizes() {
txt1 = findViewById(R.id.item_1);
txt2 = findViewById(R.id.item_2);
txt3 = findViewById(R.id.item_3);
txt4 = findViewById(R.id.item_4);
txt5 = findViewById(R.id.item_5);
f_item_1 = findViewById(R.id.f_item_1);
f_item_2 = findViewById(R.id.fl_item_2);
t1_item_1 = findViewById(R.id.t1_item_1);
tempo_item_1 = findViewById(R.id.tempo_item_1);
t2_item_2 = findViewById(R.id.t2_item_2);
tempo_item_2 = findViewById(R.id.tempo_item_2);
n_cancellature = findViewById(R.id.n_cancellature);
n_3 = findViewById(R.id.n_3);
txtSenza = findViewById(R.id.txtSenza);
txtUpper = findViewById(R.id.upperTableHeader);
txtLower = findViewById(R.id.lowerTableHeader);
txt1.setTextSize(30);
txt2.setTextSize(30);
txt3.setTextSize(30);
txt4.setTextSize(30);
txt5.setTextSize(30);
f_item_1.setTextSize(30);
f_item_2.setTextSize(30);
txtSenza.setTextSize(TypedValue.COMPLEX_UNIT_SP, 40);
txtLower.setTextSize(30);
txtUpper.setTextSize(30);
t1_item_1.setTextSize(30);
t2_item_2.setTextSize(30);
tempo_item_1.setTextSize(30);
tempo_item_2.setTextSize(30);
n_3.setTextSize(30);
n_cancellature.setTextSize(30);
}
and then finally add the following code to onCreate:
if (getWidth() > 2000) {
setLayoutMargins();
setTextSizes();
}

Shared element transition not working with second activity

Hi i am developing an app where i'm using shared element transition on textview however when i apply animation nothing happens and moreover text in other activity becomes invisible which is quite wierd i have given same transition name to both activities still i dont understand what the problem is please if someone can help me out here.
here is login activity
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.ct.listrtrial.activities.LoginActivity"
android:background="#color/colorPrimary">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:text="Login"
android:transitionName="#string/transition_name_signup"
android:id="#+id/text_login"
android:textColor="#color/White"
android:textSize="35sp" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:id="#+id/login_card"
app:cardBackgroundColor="#color/White"
app:cardCornerRadius="20dp"
app:cardElevation="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.ct.listrtrial.Custom.CustomEditText
android:layout_width="match_parent"
android:layout_height="80dp"
android:paddingLeft="10dp"
android:id="#+id/text_input_email"
>
<com.ct.listrtrial.Custom.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableLeft="#drawable/message"
android:drawablePadding="10dp"
android:hint="Email id"
android:background="#android:color/transparent"/>
</com.ct.listrtrial.Custom.CustomEditText>
<View
android:id="#+id/card_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/light_black"
/>
<com.ct.listrtrial.Custom.CustomEditText
android:layout_width="match_parent"
android:layout_height="80dp"
android:paddingLeft="10dp"
android:id="#+id/text_input_password"
>
<com.ct.listrtrial.Custom.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableLeft="#drawable/lock"
android:drawablePadding="10dp"
android:hint="Password"
android:background="#android:color/transparent"/>
</com.ct.listrtrial.Custom.CustomEditText>
</LinearLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:text="Forgot Password?"
android:id="#+id/text_forgot_password"
android:textColor="#color/White"
android:textSize="18sp" />
</RelativeLayout>
<com.ct.listrtrial.widget.CustomButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/ripple_button_effect"
android:layout_marginBottom="16dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Login"
android:id="#+id/login_button"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="OR CONNECT WITH"
android:textColor="#color/White"
android:textSize="15sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="50dp"
>
<com.ct.listrtrial.Custom.GoofleCustomImageView
android:id="#+id/facebook_image"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_centerInParent="true"
android:layout_marginRight="10dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="#drawable/facebook"
/>
<com.ct.listrtrial.Custom.GoofleCustomImageView
android:id="#+id/google_image"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/facebook_image"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="#drawable/google_plus_1" />
</RelativeLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="250dp">
<ImageView
android:id="#+id/login_page_curve"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="gotoregister"
android:src="#drawable/login_page_curve" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="horizontal"
>
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/or_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="130dp"
android:text="Or"
android:layout_marginTop="10dp"
android:textColor="#color/black"
android:textSize="17sp" />
<com.ct.listrtrial.Custom.CustomTextViewBold
android:id="#+id/register_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/or_text"
android:text="Register"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:textColor="#color/black"
android:textSize="17sp" />
</RelativeLayout>
</FrameLayout>
</LinearLayout>
Login activity
public class LoginActivity extends AppCompatActivity {
CustomEditText text_input_email,text_input_password;
CustomButton login_button;
GoofleCustomImageView google_image,facebook_image;
ImageView login_page_curve;
CustomTextViewMedium or_text,text_forgot_password,text_login;
CustomTextViewBold register_text;
View myView;
boolean isUp;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
initViews();
}
public void initViews(){
text_input_email = (CustomEditText)findViewById(R.id.text_input_email);
text_input_password = (CustomEditText)findViewById(R.id.text_input_password);
login_button = (CustomButton)findViewById(R.id.login_button);
google_image = (GoofleCustomImageView) findViewById(R.id.google_image);
facebook_image = (GoofleCustomImageView) findViewById(R.id.facebook_image);
login_page_curve = (ImageView)findViewById(R.id.login_page_curve);
or_text = (CustomTextViewMedium)findViewById(R.id.or_text);
text_forgot_password = (CustomTextViewMedium)findViewById(R.id.text_forgot_password);
register_text = (CustomTextViewBold)findViewById(R.id.register_text);
text_login = (CustomTextViewMedium)findViewById(R.id.text_login);
}
public void gotoregister(View view) {
Intent intent = new Intent(LoginActivity.this,RegisterActivity.class);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation
(LoginActivity.this,login_page_curve,
getResources().getString(R.string.transition_name_signup));
startActivity(intent,options.toBundle());
overridePendingTransition(R.anim.bottom_up,R.anim.bottom_down);
finish();
}
}

ListView Background

I have a ListView and it has a Header and Footer. Their layout in CardView. And Content list in which one must be background. Here is a picture which can be clearly seen: I now this is how it turns out:
And how to do:
I did so, ScrollView> first container>listView in second container > third container. But, unfortunately, at the bottom of the container 2 it was a huge empty space!
Is it possible to implement a so-in ListView? if so how, if not then how to implement?
UPDATE
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context=".Details.Book.BookDetails"
android:background="#color/fragment_bg">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"/>
<View android:layout_width="match_parent"
android:layout_height="3dp"
android:background="#drawable/toolbar_shadow"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar"
android:id="#+id/view5" />
<ScrollView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="#+id/scrollView6"
android:layout_below="#+id/toolbar">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toolbar">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/toolbar"
android:id="#+id/linearLayout16">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/rounded_top_layout"
android:paddingBottom="#dimen/leftPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingRight="#dimen/rightPadding"
android:paddingTop="#dimen/leftPadding">
<TextView
android:id="#+id/textviewTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="false"
android:layout_centerVertical="true"
android:text="#string/buy_det_pass_txt"
android:textColor="#color/background_color"
android:textSize="#dimen/mainLargeSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout9"
android:paddingBottom="#dimen/leftPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingRight="#dimen/rightPadding"
android:paddingTop="#dimen/leftPadding">
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/relativeLayout9"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_fullname"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvFullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout4"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_gender"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvGender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout3"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_ticknumber"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvTickNumber"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/linearLayout6"
android:layout_marginBottom="#dimen/textMargin"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buy_det_issdate"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:id="#+id/tvIssDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="Medium Text"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<kz.tem_tour.Primer.MainActivity.NonScrollListView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/listView"
android:layout_centerHorizontal="true"
android:paddingRight="#dimen/textMargin"
android:paddingLeft="#dimen/textMargin"
android:layout_below="#+id/linearLayout16" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/listView">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:background="#drawable/rounded_top_layout"
android:paddingTop="#dimen/leftPadding"
android:paddingBottom="#dimen/leftPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingRight="#dimen/rightPadding">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/buy_det_cost_txt"
android:id="#+id/tvFromTo"
android:textColor="#color/background_color"
android:textSize="#dimen/mainLargeSize"
android:layout_alignParentTop="false"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout9"
android:paddingRight="#dimen/rightPadding"
android:paddingLeft="#dimen/rightPadding"
android:paddingTop="#dimen/leftPadding"
android:paddingBottom="#dimen/leftPadding">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/relativeLayout9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout4"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_fare"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvFare"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout4"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout3"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_taxes"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvTaxes"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout3"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout6"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_service_fees"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvFees"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout6"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout7"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_total_price"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvTotPrice"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout7"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:id="#+id/linearLayout15"
android:gravity="center_vertical"
android:layout_marginBottom="#dimen/textMargin" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/buy_det_form_of_pay"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:textSize="#dimen/mainSmallSize" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Medium Text"
android:id="#+id/tvPayment"
android:layout_weight="1"
android:textColor="#color/mainGreyColor"
android:gravity="right"
android:textSize="#dimen/mainMiddleSize" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
I have solution for that.. not healthy one but it should work for you.
Rather then adding header and footer wrap all three layout inside ScrollView.
<ScrollView ... >
<CardView ... /> <!-- this will be header -->
<CardView ...>
<yourpackagename.NonScrollListView ... /> <!-- non scrollable listview -->
</CardView>
<CardView ... /> <!-- this will footer -->
</ScrollView>
Here is the class for NonScrollListView
public class NonScrollListView extends ListView {
public NonScrollListView(Context context) {
super(context);
}
public NonScrollListView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollListView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
#Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int heightMeasureSpec_custom = MeasureSpec.makeMeasureSpec(
Integer.MAX_VALUE >> 2, MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, heightMeasureSpec_custom);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
}
Add listview in CardView and above that cardview add header in different card view and same add footer in cardview under ListView cardview. And add whole layout is scrollview. Calculate height of listview at runtime and add height to listview. Your custom look is ready.
public static void setTotalHeightofListView(ListView listView) {
ListAdapter mAdapter = listView.getAdapter();
int totalHeight = 0;
for (int i = 0; i < mAdapter.getCount(); i++) {
View mView = mAdapter.getView(i, null, listView);
mView.measure(
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED),
MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
totalHeight += mView.getMeasuredHeight();
Log.w("HEIGHT" + i, String.valueOf(totalHeight));
}
ViewGroup.LayoutParams params = listView.getLayoutParams();
params.height = totalHeight
+ (listView.getDividerHeight() * (mAdapter.getCount() - 1));
listView.setLayoutParams(params);
listView.requestLayout();
}

Could not find TextView by calling findViewById method [duplicate]

This question already has answers here:
Can not find a View with findViewById()
(4 answers)
Closed 8 years ago.
My main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background"
android:orientation="horizontal"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="ua.example.eventorganizer.MainActivity" >
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="50dp" >
<FrameLayout
android:id="#+id/FrameLayout02"
android:layout_width="50dp"
android:layout_height="fill_parent" >
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal" >
<TextView
android:id="#+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Счёт"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView04"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Сет 1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView05"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Сет 2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView06"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Сет 3"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView07"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Сет 4"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView08"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Сет 5"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout01"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/linearLayout2" >
<FrameLayout
android:id="#+id/FrameLayout01"
android:layout_width="50dp"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/ImageView01"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/ic_launcher2" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal" >
<TextView
android:id="#+id/Score_One"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="40"
android:textAppearance="?android:attr/textAppearanceLarge"
android:onClick="ScoreOne"
android:clickable="true"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="7"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="4"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="5"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="7"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView09"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="6"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/LinearLayout02"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentLeft="true"
android:layout_below="#+id/LinearLayout01" >
<FrameLayout
android:id="#+id/FrameLayout03"
android:layout_width="50dp"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/ImageView03"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/ic_launcher2" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_gravity="center_vertical|center_horizontal" >
<TextView
android:id="#+id/TextView17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:onClick="ScoreTwo"
android:clickable="true"
android:text="15"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="5"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="6"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="6"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="3"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
<FrameLayout
android:layout_width="50dp"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/TextView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="4"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</FrameLayout>
</LinearLayout>
</RelativeLayout>
My code:
import android.app.Activity;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
public class FilterActivity extends Activity {
private static final int TEXT_ID = 0;
EditText ScoreOne;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ScoreOne = (EditText) findViewById(R.id.Score_One);
}
debug say - not found in
ScoreOne = (EditText) findViewById(R.id.Score_One);
What wrong?
Your Score_One is a TextView and it cannot be cast to EditText - you get a ClassCastException.
Change
EditText ScoreOne;
to
TextVIew ScoreOne;
and the (EditText) cast to (TextView).
Score_One is the TextView. It's not EditText. You're not casting as TextView
try this
TextView ScoreOne = (TextView ) findViewById(R.id.Score_One);
TextView cannot cast to EditText
Change EditText Score_one;---->Textview Score_one;
None of the textview id having Score_one as i checked in above main.xml
main.xml
<TextView
android:id="#+id/Score_One"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:text="Счёт"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#android:color/white" />
Activity.java
TextView ScoreOne = (TextView ) findViewById(R.id.Score_One);

Categories