in Fragment remove blank space from layout : CollapsingToolbarLayout +NestedScrollView + ViewPager - android

Problem :
unable to find solution for remove blank space layout
Image :
GIF Image :
Main screen is my HomeFragment in which i use CollapsingToolbarLayout ,NestedScrollView and ViewPager and in ViewPager load 3 Fragments code is below
private void setupViewPager(ViewPager viewPager) {
HomeFragment.ViewPagerAdapter adapter = new HomeFragment.ViewPagerAdapter(getChildFragmentManager());
adapter.addFragment(new InstantFragment(), "Instant");
adapter.addFragment(new LimitFragment(), "Limit");
adapter.addFragment(new StopFragment(), "Stop");
viewPager.setAdapter(adapter);
}
Here is my fragment_home.xml code
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/ll_home_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#mipmap/ic_app_background">
<android.support.design.widget.CoordinatorLayout 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_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleGravity="top"
app:expandedTitleMarginStart="10dp"
app:expandedTitleMarginTop="20dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:id="#+id/llChild"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout
android:id="#+id/llview_relative"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
android:gravity="center"
android:orientation="horizontal">
<Spinner
android:id="#+id/spinner_currency"
android:layout_width="200dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="20dp" />
<Button
android:id="#+id/btndeposit"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginLeft="#dimen/margin10"
android:layout_marginRight="#dimen/margin20"
android:background="#color/pink"
android:text="Deposit"
android:textAllCaps="false"
android:textColor="#color/white"
android:textSize="16dp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_margin="#dimen/margin10"
android:layout_marginTop="#dimen/margin10"
android:orientation="vertical"
android:background="#mipmap/ic_app_background">
<com.github.mikephil.charting.charts.CandleStickChart
android:id="#+id/chart1"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<WebView
android:id="#+id/webView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fitsSystemWindows="true"
android:scrollbars="none" />
</LinearLayout>
<TextView
android:id="#+id/txt_my_opn_order"
android:layout_marginTop="#dimen/margin10"
android:text="#string/my_open_orders_title"
android:textSize="17sp"
android:fontFamily="#font/poppins_light"
android:textColor="#color/notification_title"
android:layout_marginLeft="#dimen/margin5"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<FrameLayout
android:id="#+id/sub_frame_container"
android:layout_width="match_parent"
android:visibility="gone"
android:animateLayoutChanges="true"
android:layout_height="wrap_content"/>
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<TextView
android:layout_marginTop="#dimen/margin10"
android:text="#string/new_orders_title"
android:textSize="17sp"
android:fontFamily="#font/poppins_light"
android:textColor="#color/notification_title"
android:layout_marginLeft="#dimen/margin5"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<com.bacancy.kryptonight.customviews.CustomViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
here is code for CustomViewPager
public class CustomViewPager extends ViewPager {
public CustomViewPager(Context context) {
super(context);
}
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
}
#Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
int height = 0;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if (h > height) height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
here is 1st Fragment fragment_instant.xml code
<?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="match_parent"
android:background="#2C2f33"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="#dimen/margin20"
android:layout_marginTop="#dimen/margin10"
android:gravity="center"
android:text="#string/spend_title"
android:textColor="#color/white"
android:textSize="#dimen/margin20" />
<EditText
android:id="#+id/edtspend"
android:layout_width="match_parent"
android:layout_height="#dimen/edittext_height"
android:layout_marginLeft="#dimen/margin20"
android:layout_marginRight="#dimen/margin20"
android:textColor="#color/white"
android:background="#color/edittext_background"
android:hint="Amount"
android:maxLength="20"
android:inputType="number"
android:paddingLeft="#dimen/margin5" />
<TextView
android:id="#+id/txtsubtotal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin20"
android:layout_marginRight="#dimen/margin20"
android:layout_marginTop="#dimen/margin10"
android:visibility="gone"
android:text="#string/subtotal"
android:textColor="#color/textcolor" />
<TextView
android:id="#+id/txtfee"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin20"
android:visibility="gone"
android:text="#string/fee"
android:textColor="#color/textcolor" />
<CheckBox
android:layout_margin="#dimen/margin20"
android:id="#+id/chkisPartialBuy"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin20"
android:buttonTint="#color/button_buy"
android:text="#string/is_partial_title"
android:textColor="#color/textcolor"
android:textSize="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginLeft="#dimen/margin20"
android:layout_marginRight="#dimen/margin20"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/approx"
android:textColor="#color/textcolor" />
<TextView
android:layout_marginLeft="#dimen/margin10"
android:id="#+id/txtapprox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:ellipsize="end"
android:text="#string/approx_def_price_buy"
android:textColor="#color/textcolor" />
</LinearLayout>
<Button
android:id="#+id/btnbuy"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin20"
android:layout_marginRight="#dimen/margin20"
android:layout_marginTop="#dimen/margin30"
android:background="#color/button_buy"
android:text="#string/buy"
android:textColor="#color/white" />
<TextView
android:layout_width="match_parent"
android:layout_height="2dp"
android:layout_marginTop="#dimen/margin20"
android:background="#color/line" />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_margin="#dimen/margin20"
android:layout_marginTop="#dimen/margin10"
android:gravity="center"
android:text="#string/sell_title"
android:textColor="#color/white"
android:textSize="#dimen/margin20" />
<EditText
android:id="#+id/edtsell"
android:layout_width="match_parent"
android:layout_height="#dimen/edittext_height"
android:layout_marginLeft="#dimen/margin20"
android:textColor="#color/white"
android:inputType="numberDecimal"
android:layout_marginRight="#dimen/margin20"
android:maxLength="20"
android:background="#color/edittext_background"
android:hint="Amount"
android:paddingLeft="#dimen/margin5" />
<TextView
android:id="#+id/txtsubtotal_sell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin20"
android:layout_marginRight="#dimen/margin20"
android:layout_marginTop="#dimen/margin10"
android:text="#string/subtotal"
android:visibility="gone"
android:textColor="#color/textcolor" />
<TextView
android:id="#+id/txtfee_sell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/margin20"
android:visibility="gone"
android:text="#string/fee"
android:textColor="#color/textcolor" />
<CheckBox
android:layout_margin="#dimen/margin20"
android:id="#+id/chkisPartialSell"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin20"
android:buttonTint="#color/button_sell"
android:text="#string/is_partial_title"
android:textColor="#color/textcolor"
android:textSize="16dp" />
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginLeft="#dimen/margin20"
android:layout_marginRight="#dimen/margin20"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/approx"
android:textColor="#color/textcolor" />
<TextView
android:id="#+id/txtapprox_sell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin10"
android:maxLines="1"
android:ellipsize="end"
android:text="#string/approx_def_price_sell"
android:textColor="#color/textcolor" />
</LinearLayout>
<Button
android:id="#+id/btnsell"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/margin60"
android:layout_marginLeft="#dimen/margin20"
android:layout_marginRight="#dimen/margin20"
android:layout_marginTop="#dimen/margin30"
android:background="#color/button_sell"
android:text="#string/sell"
android:textColor="#color/white" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
i check CustomViewPager class where height set how can we set height current view to WRAP_CONTENT

Related

Moving from one activity to another takes a long time

Within my application I could notice that each time I went from one activity to another it took a long time (1 second or more), when it should be almost instantly. I did the test on my own cell phone and it takes about 2 seconds. I tested on a newer (more powerful) one, it takes less but still takes longer than it should.
I don't know if my activities are very loaded or if I am calling them in the wrong way.
Call to activities from my MainActivity:
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Toolbar toolbar;
private Anuncio anuncio;
private TextView titulo;
private CardView cardView1, cardView2, cardView3, cardView4;
private View include_1, include_2, include_3, include_4, include_5, include_6, include_7, include_8, include_9;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.contenedor_principal);
anuncio = new Anuncio();
anuncio.cargarAnuncios(this, R.id.adView_alone);
toolbar = findViewById(R.id.toolbar_alone);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) getSupportActionBar().setTitle(null);
titulo = findViewById(R.id.textview_toolbar_titulo_alone);
titulo.setText(R.string.app_name);
inicializar();
}
private void inicializar() {
include_1 = findViewById(R.id.include_objetivos);
include_1.setVisibility(View.GONE);
include_2 = findViewById(R.id.include_compras);
include_2.setVisibility(View.GONE);
include_3 = findViewById(R.id.include_porCuentas);
include_3.setVisibility(View.GONE);
include_4 = findViewById(R.id.include_porQuincena);
include_4.setVisibility(View.GONE);
include_5 = findViewById(R.id.include_porInteres);
include_5.setVisibility(View.GONE);
include_6 = findViewById(R.id.include_lista_ahorros);
include_6.setVisibility(View.GONE);
include_7 = findViewById(R.id.include_ingresos);
include_7.setVisibility(View.GONE);
include_8 = findViewById(R.id.include_deudas);
include_8.setVisibility(View.GONE);
include_9 = findViewById(R.id.include_home_menu);
include_9.setVisibility(View.VISIBLE);
cardView1 = findViewById(R.id.menu_cardView_1);
cardView2 = findViewById(R.id.menu_cardView_2);
cardView3 = findViewById(R.id.menu_cardView_3);
cardView4 = findViewById(R.id.menu_cardView_4);
cardView1.setOnClickListener(this);
cardView2.setOnClickListener(this);
cardView3.setOnClickListener(this);
cardView4.setOnClickListener(this);
}
#Override
public void onClick(View v) {
Intent intent;
switch (v.getId()) {
case R.id.menu_cardView_1:
intent = new Intent(this, Menu1.class);
this.startActivity(intent);
break;
case R.id.menu_cardView_2:
intent = new Intent(this, Menu2.class);
this.startActivity(intent);
break;
case R.id.menu_cardView_3:
intent = new Intent(this, Menu3.class);
this.startActivity(intent);
break;
case R.id.menu_cardView_4:
intent = new Intent(this, Menu4.class);
this.startActivity(intent);
break;
}
}
#Override
public void onPause() {
anuncio.pausar();
super.onPause();
}
#Override
public void onResume() {
super.onResume();
anuncio.resumir();
}
#Override
public void onDestroy() {
anuncio.destruir();
super.onDestroy();
}
}
XML from my MainActivity:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#color/colorAccent">
<TextView
android:id="#+id/menu_titulo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textColor="#color/blanco"
android:textStyle="bold"
android:textSize="30sp"
android:shadowColor="#color/negro_semi_transparente"
android:shadowDx="10"
android:shadowDy="10"
android:shadowRadius="6"
android:text="MenĂº Principal"
android:padding="15dp"
android:layout_marginTop="30dp" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/menu_titulo"
android:rowCount="2"
android:columnCount="2"
android:padding="20dp">
<androidx.cardview.widget.CardView
android:id="#+id/menu_cardView_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/regalo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Regalos"
android:textStyle="bold"
android:textAlignment="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/menu_cardView_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_column="1"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/carro"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Carros"
android:textStyle="bold"
android:textAlignment="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/menu_cardView_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_column="0"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="15dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/casa"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Casas"
android:textStyle="bold"
android:textAlignment="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/menu_cardView_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_column="1"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginTop="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="15dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:layout_gravity="center_vertical|center_horizontal">
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/cine"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cine"
android:textStyle="bold"
android:textAlignment="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</GridLayout>
Activity Regalo XML:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#drawable/menu_fondo_3"
android:orientation="vertical">
<TextView
android:id="#+id/titulo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textColor="#color/blanco"
android:textStyle="bold"
android:textSize="30sp"
android:shadowColor="#color/negro_semi_transparente"
android:shadowDx="10"
android:shadowDy="10"
android:shadowRadius="6"
android:text="Regalos"
android:padding="15dp"
android:layout_marginTop="30dp" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/titulo"
android:rowCount="3"
android:columnCount="1"
android:padding="20dp">
<androidx.cardview.widget.CardView
android:id="#+id/regalo1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_column="0"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="15dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center_vertical|center_horizontal"
android:padding="15dp">
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/regalo"
android:layout_marginEnd="15dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Regalo 1"
android:textStyle="bold"
android:textSize="20sp"
android:textAlignment="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/regalo2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_column="0"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_margin="15dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center_vertical|center_horizontal"
android:padding="15dp">
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/regalo"
android:layout_marginEnd="15dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Regalo 2"
android:textStyle="bold"
android:textSize="20sp"
android:textAlignment="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/regalo3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_row="2"
android:layout_column="0"
android:layout_gravity="fill"
android:layout_rowWeight="1"
android:layout_columnWeight="1"
android:layout_marginTop="15dp"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp"
android:layout_marginBottom="20dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center"
android:layout_gravity="center_vertical|center_horizontal"
android:padding="15dp">
<ImageView
android:layout_width="65dp"
android:layout_height="65dp"
android:src="#drawable/regalo"
android:layout_marginEnd="15dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Regalo 3"
android:textStyle="bold"
android:textSize="20sp"
android:textAlignment="center"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</GridLayout>
All these XML are inside each other through an 'include'. Here below I leave the code of the main_container.xml:
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- Inicio de la Appbar -->
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<!-- Inicio de la Toolbar-->
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar_alone"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" >
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textview_toolbar_titulo_alone"
android:text="#string/app_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="23sp"
android:textStyle="bold"
android:textColor="#color/blanco" />
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
<!-- Fin de la Toolbar-->
</com.google.android.material.appbar.AppBarLayout>
<include
android:id="#+id/include_menu"
layout="#layout/menu_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_1"
layout="#layout/layout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_2"
layout="#layout/layout2"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_3"
layout="#layout/layout3"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_4"
layout="#layout/layout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_5"
layout="#layout/layout5"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_6"
layout="#layout/layout6"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_7"
layout="#layout/layout7"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_8"
layout="#layout/layout8"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<include
android:id="#+id/include_9"
layout="#layout/layout9"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_marginBottom="90dp"
android:visibility="gone"/>
<com.google.android.gms.ads.AdView
android:id="#+id/adView_alone"
ads:adSize="SMART_BANNER"
ads:adUnitId="#string/banner_ad_unit_id"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:layout_anchorGravity="bottom|center" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Thanks in advance.
translated by google translate.
I removed all the 'include' and used a single ViewStub to load the layouts depending on which one the user wanted to see.
Main_container.xml:
<ViewStub
android:id="#+id/viewStub"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
MainActivity:
viewStub = findViewById(R.id.viewStub);
viewStub.setLayoutResource(R.layout.home_layout);
viewStub.inflate();

How to limit ListView to particular number of list items?

I am working on a functionality in which I have a ListView and I want listView to show only 3 items. I have set ListView height to "wrap_content" and in adapter I have set get count to 3 so that it will show only 3 items but it is showing only 1 item. I am not able to figure out what is happening.My API is returing only 3 items but not able to show all the items in ListView.
Adapter Code:
public class Adapter3Testimonials extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater = null;
private Context context;
public Adapter3Testimonials(Activity a, ArrayList<HashMap<String, String>> d) {
activity = a;
this.data = d;
context = a;
inflater = (LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(final int position, View convertView, ViewGroup parent) {
View itemView = inflater.inflate(R.layout.item_3_testimonials, parent, false);
TextView txtTestimonial = (TextView) itemView.findViewById(R.id.txtAdvisorTestimonails);
Log.e("TAG", "item_3_testimonials: " + position);
HashMap<String, String> testimonialsList;
testimonialsList = new HashMap<String, String>();
testimonialsList = data.get(position);
txtTestimonial.setText(testimonialsList.get("description"));
return itemView;
}
}
Xml:
<RelativeLayout 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">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp10"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp5">
<FrameLayout
android:id="#+id/layImageProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/dp5"
android:background="#drawable/half_blue_circle">
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="#dimen/dp80"
android:layout_height="#dimen/dp80"
android:padding="#dimen/dp2"
android:src="#drawable/blank_profile" />
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher_background"
android:visibility="gone"
app:civ_border_width="2dp" />
<ImageView
android:id="#+id/imgBlockUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/profile_image2"
android:layout_gravity="right"
android:src="#drawable/phone" />
</FrameLayout>
<TextView
android:id="#+id/txtName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="#dimen/dp13"
android:layout_toRightOf="#+id/layImageProfile"
android:text="John doe"
android:textColor="#android:color/black"
android:textSize="#dimen/dp15" />
<TextView
android:id="#+id/txtFirmName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/txtName"
android:layout_alignStart="#id/txtName"
android:layout_below="#id/txtName"
android:text="Demo Corp. Inc."
android:textColor="#android:color/black" />
<TextView
android:id="#+id/txtRnf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/txtFirmName"
android:layout_alignStart="#id/txtFirmName"
android:layout_below="#id/txtFirmName"
android:text="Rnf No #12234"
android:textColor="#android:color/black" />
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="#+id/imgReviewStarts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#id/txtRnf"
android:layout_below="#id/txtRnf"
android:layout_marginTop="#dimen/dp5"
android:layout_toRightOf="#id/layImageProfile"
app:srb_borderColor="#color/colorPrimary"
app:srb_fillColor="#color/colorPrimary"
app:srb_isIndicator="true"
app:srb_numberOfStars="5"
app:srb_starBorderWidth="1.0"
app:srb_starCornerRadius="2.5"
app:srb_starSize="#dimen/dp15"
app:srb_stepSize="1" />
<ImageView
android:id="#+id/imgClickToConnect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="#dimen/dp25"
android:src="#drawable/click" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/dp1"
android:layout_marginTop="#dimen/dp10"
android:background="#color/colorPrimary" />
<TextView
android:id="#+id/txtStatement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp5"
android:background="#color/colorPrimary"
android:paddingBottom="#dimen/dp5"
android:paddingLeft="#dimen/dp5"
android:paddingTop="#dimen/dp3"
android:text="Mission statement Lorum ipsum dolar sit or elit lamet,consector cillium"
android:textColor="#android:color/white" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/dp1"
android:layout_marginTop="#dimen/dp5"
android:background="#color/colorPrimary" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp5"
android:paddingLeft="#dimen/dp10"
android:text="#string/customer_review_score"
android:textColor="#android:color/black"
android:textSize="#dimen/dp15" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/dp10"
android:progress="100"
android:progressTint="#android:color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/buying_exp" />
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="#+id/imgBuyingExp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtRnf"
android:layout_marginLeft="#dimen/dp20"
app:srb_borderColor="#color/colorPrimary"
app:srb_fillColor="#color/colorPrimary"
app:srb_isIndicator="true"
app:srb_numberOfStars="5"
app:srb_starBorderWidth="1.0"
app:srb_starCornerRadius="2.5"
app:srb_starSize="#dimen/dp15"
app:srb_stepSize="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/knowledge_comp" />
<com.iarcuschin.simpleratingbar.SimpleRatingBar
android:id="#+id/imgKnowledgeComp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtRnf"
android:layout_marginLeft="#dimen/dp20"
app:srb_borderColor="#color/colorPrimary"
app:srb_fillColor="#color/colorPrimary"
app:srb_isIndicator="true"
app:srb_numberOfStars="5"
app:srb_starBorderWidth="1.0"
app:srb_starCornerRadius="2.5"
app:srb_starSize="#dimen/dp15"
app:srb_stepSize="1" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:orientation="horizontal"
android:weightSum="1">
<TextView
android:id="#+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.9"
android:text="#string/percentage_of_customer" />
<TextView
android:id="#+id/txtPercentageRecommended"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="#dimen/dp20"
android:layout_toRightOf="#id/txt"
android:text="100%" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/dp1"
android:layout_marginTop="#dimen/dp10"
android:background="#color/colorPrimary" />
<LinearLayout
android:id="#+id/layTestimonials"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp5"
android:background="#color/colorPrimary"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/dp10"
android:paddingTop="#dimen/dp10"
android:text="#string/customer_testimonials"
android:textColor="#android:color/white"
android:textSize="#dimen/dp15" />
<TextView
android:id="#+id/btnTestimonialNumber"
android:layout_width="#dimen/dp35"
android:layout_height="#dimen/dp35"
android:layout_gravity="center_vertical"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp5"
android:layout_toRightOf="#id/textView"
android:background="#drawable/round_button"
android:padding="#dimen/dp5"
android:text=""
android:textAlignment="center"
android:textColor="#color/colorPrimary" />
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView"
android:paddingLeft="#dimen/dp10"
android:progress="100"
android:progressTint="#android:color/white" />
</RelativeLayout>
<TextView
android:id="#+id/noTestimonial"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="#dimen/dp20"
android:layout_marginTop="#dimen/dp20"
android:gravity="center"
android:text="#string/no_testimonials"
android:textColor="#android:color/white"
android:visibility="gone" />
<ListView
android:id="#+id/listCustomer_testimonial"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
android:divider="#android:color/white">
</ListView>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/dp1"
android:layout_marginTop="#dimen/dp5"
android:background="#color/colorPrimary" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dp10"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/dp5"
android:text="Years of experience:"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/txtAdExperience"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp8"
android:text="2" />
</LinearLayout>
<TextView
android:id="#+id/txtExpertise"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="#dimen/dp5"
android:text="#string/expertise"
android:textColor="#android:color/black"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/dp5"
android:orientation="horizontal">
<TextView
android:id="#+id/btnProtect_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp5"
android:background="#drawable/bg_skyblue"
android:padding="#dimen/dp5"
android:text="#string/protect_money"
android:textAllCaps="false"
android:textColor="#android:color/white"
android:visibility="gone" />
<TextView
android:id="#+id/btnGrow_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp5"
android:background="#drawable/bg_skyblue"
android:padding="#dimen/dp5"
android:text="#string/grow_money"
android:textColor="#android:color/white"
android:visibility="gone" />
<TextView
android:id="#+id/btnMedical_Needs"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dp5"
android:background="#drawable/bg_skyblue"
android:padding="#dimen/dp5"
android:text="#string/medical_need"
android:textColor="#android:color/white"
android:visibility="gone" />
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="#dimen/dp15"
android:layout_marginLeft="#dimen/dp10"
android:layout_marginTop="#dimen/dp10">
<TextView
android:id="#+id/txtSocialMedia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/find_me_on_social_media"
android:textColor="#android:color/black"
android:textSize="#dimen/dp15" />
<ImageView
android:id="#+id/imgFB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtSocialMedia"
android:layout_marginTop="#dimen/dp10"
android:src="#drawable/fb_icon" />
<ImageView
android:id="#+id/imgYoutube"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtSocialMedia"
android:layout_marginLeft="#dimen/dp5"
android:layout_marginTop="#dimen/dp10"
android:layout_toRightOf="#id/imgFB"
android:src="#drawable/youtube_icon" />
<ImageView
android:id="#+id/imgLinkden"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtSocialMedia"
android:layout_marginLeft="#dimen/dp5"
android:layout_marginTop="#dimen/dp10"
android:layout_toRightOf="#id/imgYoutube"
android:src="#drawable/linkedin_icon" />
<ImageView
android:id="#+id/imgRSS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/txtSocialMedia"
android:layout_marginLeft="#dimen/dp5"
android:layout_marginTop="#dimen/dp10"
android:layout_toRightOf="#id/imgLinkden"
android:src="#drawable/rss_icon" />
<ImageView
android:id="#+id/imgCartoon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_toRightOf="#id/txtSocialMedia"
android:src="#drawable/man_after_feedback" />
<ImageView
android:id="#+id/imgRead_my_articles"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_below="#id/imgFB"
android:layout_marginTop="#dimen/dp10"
android:src="#drawable/read_my_articles" />
<ImageView
android:id="#+id/imgClick_for_feedback"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#id/imgFB"
android:layout_marginRight="#dimen/dp10"
android:layout_marginTop="#dimen/dp10"
android:src="#drawable/click_for_feedback" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
<ProgressBar
android:id="#+id/pBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone" />
Inside this code I have ListView with id "listCustomer_testimonial".
Never use ListView inside Scrollview. But if you must use ListView inside ScrollView create a scrollhandler.
public class scrollhandler {
public static void getListViewSize(ListView myListView) {
ListAdapter myListAdapter = myListView.getAdapter();
if (myListAdapter == null) {
//do nothing return null
return;
}
//set listAdapter in loop for getting final size
int totalHeight = 0;
int rowheight=56;
for (int size = 0; size < myListAdapter.getCount(); size++) {
View listItem = myListAdapter.getView(size, null, myListView);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
rowheight=listItem.getMeasuredHeight();
}
//setting listview item in adapter
ViewGroup.LayoutParams params = myListView.getLayoutParams();
params.height = totalHeight + (myListView.getDividerHeight() * (myListAdapter.getCount() - 1));
myListView.setLayoutParams(params);
// print height of adapter on log
Log.i("height of listItem:", String.valueOf(totalHeight)+","+myListAdapter.getCount());
}
}
Then lastly bind the ListView with the Handler
lv.setAdapter(adapter);
scrollhandler.getListViewSize(lv);
Your problem is not with the getCount() method or list items count.
You have used listview inside scrollview, so only one item will be visible and others can be seen on scroll.
You can use custom Listview to avoid issue in height of listview,
public class NonScrollableListview extends ListView {
public NonScrollableListview(Context context) {
super(context);
}
public NonScrollableListview(Context context, AttributeSet attrs) {
super(context, attrs);
}
public NonScrollableListview(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();
}
}
In your xml ,
<com.yourpack.NonScrollableListview
android:id="#+id/list_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Or use NestedScrollView with RecyclerView instead of listview.
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:fillViewport="true">
<!--otherviews-->
<android.support.v7.widget.RecyclerView
android:id="#+id/list_detail"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<!--otherviews-->
</android.support.v4.widget.NestedScrollView>

Recyclerview items unable scroll down.inside tabpane

used tabpane take 120dp height in top.
mainxml:
<?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"
android:background="#E0E0E0"
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="com.example.suranpc.recy.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="120dp"
android:scrollbars="vertical"
/>
</RelativeLayout>
cardview design xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="3dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:padding="16dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="16dp"
>
<TextView
android:id="#+id/firstcardtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView"
android:textColor="#color/colorFontblack"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="60dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="4dp"
>
<TextView
android:id="#+id/firstcardtext2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="TextView :"
android:textAlignment="center"
android:textColor="#color/colorFontblack"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/firstcardtext3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.91"
android:gravity="right"
android:text="TextView"
android:textAlignment="center"
android:textColor="#color/colorPrimaryDark"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="1dp"
>
<TextView
android:id="#+id/firstcardtext4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.92"
android:gravity="left"
android:text="TextView:"
android:textAlignment="center"
android:textColor="#color/colorFontblack"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/firstcardtext5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.98"
android:gravity="right"
android:text="20000"
android:textAlignment="center"
android:textColor="#color/colorFontheader"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="180dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="1dp"
>
<TextView
android:id="#+id/firstcardtext6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="TextView:"
android:textAlignment="center"
android:textColor="#color/colorFontblack"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/firstcardtext7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="TextView"
android:textAlignment="center"
android:textColor="#color/colorFontheader"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
recycler adapter code:
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
public class Readapter extends RecyclerView.Adapter<Readapter.ProductViewHolder> {
//this context we will use to inflate the layout
private Context mCtx;
//we are storing all the products in a list
private List<Front> productList;
//getting the context and product list with constructor
public Readapter(Context mCtx, List<Front> productList) {
this.mCtx = mCtx;
this.productList = productList;
}
#Override
public ProductViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
//inflating and returning our view holder
LayoutInflater inflater = LayoutInflater.from(mCtx);
View view=LayoutInflater.from(parent.getContext()).inflate(R.layout.layoutte,parent,false);
return new ProductViewHolder(view);
}
#Override
public void onBindViewHolder(ProductViewHolder holder, int position) {
//getting the product of the specified position
Front product = productList.get(position);
//binding the data with the viewholder views
holder.textView1.setText(product.getbud());
holder.textView2.setText(product.getbudnum());
holder.textView3.setText(product.gettosp());
holder.textView4.setText(product.gettospnum());
holder.textView5.setText(product.getrem());
holder.textView6.setText(product.getremnum());
holder.textView7.setText(product.getremnums());
}
#Override
public int getItemCount() {
return productList.size();
}
class ProductViewHolder extends RecyclerView.ViewHolder {
TextView textView1, textView2, textView3, textView4, textView5,textView6,textView7;
public ProductViewHolder(View itemView) {
super(itemView);
textView1 = itemView.findViewById(R.id.firstcardtext);
textView2 = itemView.findViewById(R.id.firstcardtext2);
textView3 = itemView.findViewById(R.id.firstcardtext3);
textView4 = itemView.findViewById(R.id.firstcardtext4);
textView5 = itemView.findViewById(R.id.firstcardtext5);
textView6 = itemView.findViewById(R.id.firstcardtext6);
textView7 = itemView.findViewById(R.id.firstcardtext7);
}
}
}
Mainactivity code(add datas):
recyclerView=(RecyclerView) findViewById(R.id.recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
productList =new ArrayList<>();
productList.add(new
Front("tested1","tested","tested","tested","tested","tested","tested"));
productList.add(new
Front("tested2","tested","tested","tested","tested","tested","tested"));
productList.add(new
Front("tested3","tested","tested","tested","tested","tested","tested"));
productList.add(new Front("tested4","tested","tested","tested","tested","tested","tested"));
Readapter adapter=new Readapter(this,productList);
recyclerView.setAdapter(adapter);
only two cards are visible in screen.another two cards not visibled.fixed height datas only showed.(not scrolled).
only test1 and test2 datas visible in screen another test3 abd test4 not viewd and scrolled .
appbar xml code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
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"
tools:context="com.example.suranpc..MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<android.support.design.widget.TabLayout
android:background="#color/colorTabbg"
app:tabSelectedTextColor="#color/colorFontwhite"
app:tabIndicatorColor="#color/colorFontwhite"
app:tabIndicatorHeight="4dp"
app:tabTextColor="#color/colorFontblack"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabGravity="fill"
android:id="#+id/tbl_pages"/>
<!-- <tabbed pane" />-->
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/vp_pages"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v4.view.ViewPager>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#android:drawable/ic_dialog_email" />
</FrameLayout>
</android.support.design.widget.CoordinatorLayout>
tabpane code in mainactivity
//the tabpane>
ViewPager vp_pages= (ViewPager) findViewById(R.id.vp_pages);
PagerAdapter pagerAdapter=new FragmentAdapter(getSupportFragmentManager());
vp_pages.setAdapter(pagerAdapter);
TabLayout tbl_pages= (TabLayout) findViewById(R.id.tbl_pages);
final int[]ICONS=new int[]{
R.drawable.ic_menu_camera, R.drawable.ic_menu_camera, R.drawable.ic_menu_camera, R.drawable.ic_menu_camera,
};
tbl_pages.setupWithViewPager(vp_pages);
tbl_pages.getTabAt(0).setIcon(ICONS[0]);
tbl_pages.getTabAt(1).setIcon(ICONS[1]);
tbl_pages.getTabAt(2).setIcon(ICONS[2]);
tbl_pages.getTabAt(3).setIcon(ICONS[3]);
//<tabpane>
Try this just Change this in your cardview design xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<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_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:layout_marginTop="5dp"
android:padding="16dp"
app:cardCornerRadius="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="16dp"
>
<TextView
android:id="#+id/firstcardtext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="TextView"
android:textColor="#color/colorFontblack"
android:textSize="20dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="60dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="4dp"
>
<TextView
android:id="#+id/firstcardtext2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="TextView :"
android:textAlignment="center"
android:textColor="#color/colorFontblack"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/firstcardtext3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.91"
android:gravity="right"
android:text="TextView"
android:textAlignment="center"
android:textColor="#color/colorPrimaryDark"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="120dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="1dp"
>
<TextView
android:id="#+id/firstcardtext4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.92"
android:gravity="left"
android:text="TextView:"
android:textAlignment="center"
android:textColor="#color/colorFontblack"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/firstcardtext5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.98"
android:gravity="right"
android:text="20000"
android:textAlignment="center"
android:textColor="#color/colorFontheader"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="180dp"
android:background="#ffffff"
android:orientation="horizontal"
android:padding="1dp"
>
<TextView
android:id="#+id/firstcardtext6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:text="TextView:"
android:textAlignment="center"
android:textColor="#color/colorFontblack"
android:textSize="22dp"
android:textStyle="bold" />
<TextView
android:id="#+id/firstcardtext7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:text="TextView"
android:textAlignment="center"
android:textColor="#color/colorFontheader"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
EDIT
<?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:background="#E0E0E0"
tools:context="com.example.suranpc.recy.MainActivity">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:layout_marginTop="120dp"
android:scrollbars="vertical" />
</LinearLayout>
Display content main xml behalf of tabpane fragment(home page xml).use fragment it works.

Shared elements in fragments dont work, textview -> edittext

I have 2 fragments, and want to do a shared element transition between them.
The item in an recyclerview, with an adapter, contains a textview that should be animated to an edittext in the next fragment.
The recyclerview is in an fragment too.
Here's my code:
item layout for viewholder from adapter:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/row_container"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:background="#FAFAFA"
android:elevation="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:elevation="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="5dp"
android:elevation="0dp"
>
<RelativeLayout
android:layout_width="40dp"
android:layout_height="40dp"
android:background="#null"
android:elevation="0dp"
android:layout_centerVertical="true"
>
<ImageButton
android:id="#+id/notify_btn"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_bookmark_black_24dp"
android:background="#null"
android:tint="#9E9E9E"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="20dp"
android:textSize="18sp"
android:textStyle="bold"
android:textColor="#android:color/black"
android:layout_alignParentTop="true"
android:maxLines="1"
android:ellipsize="end"
android:transitionName="title"
/>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text"
android:layout_below="#id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="40dp"
android:layout_marginRight="20dp"
android:textSize="15sp"
android:maxLines="2"
android:layout_alignParentBottom="true"
android:textColor="#android:color/black"
android:ellipsize="end"
android:transitionName="text"
/>
</RelativeLayout>
<ImageView
android:id="#+id/fav"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:visibility="invisible"
android:src="#drawable/ic_star_black_24dp"
/>
</RelativeLayout>
MyAdapter class, the item row click:
row.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Fragment frag = new Fragment_Notice();
int tin_title = Integer.parseInt(String.valueOf(title.getText().length()));
if ( (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) &&
( SharedPrefHelper.getBool("shared_transition") == true) &&
( tin_title >= 1 ) ) {
//Exit transition for old fragment
frag.setSharedElementReturnTransition(TransitionInflater.from(context).inflateTransition(R.transition.title_transform));
frag.setExitTransition(TransitionInflater.from(context).inflateTransition(android.R.transition.explode));
//Enter transition for new fragment
frag.setSharedElementEnterTransition(TransitionInflater.from(context).inflateTransition(R.transition.title_transform));
frag.setEnterTransition(TransitionInflater.from(context).inflateTransition(android.R.transition.explode));
ft.replace(R.id.container, frag, "NoticeTag")
.addToBackStack(null)
.addSharedElement(title, "title")
.commit();
} else {
int open = R.anim.abc_fade_in;
int close = R.anim.abc_fade_out;
ft.setCustomAnimations(open, close, open, close)
.replace(R.id.container, frag, "NoticeTag")
.addToBackStack(null)
.commit();
}
}
});
Layout from final fragment:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="10dp"
android:padding="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<EditText
android:id="#+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:nextFocusForward="#id/text"
android:imeOptions="actionNext"
android:singleLine="true"
android:ems="16"
android:hint="#string/title"
android:textColor="#212121"
android:textColorHint="#757575"
android:background="#null"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:scrollbars="horizontal"
android:transitionName="title"
/>
<EditText
android:id="#+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/text"
android:textColor="#212121"
android:textColorHint="#757575"
android:background="#null"
android:layout_marginLeft="2dp"
android:transitionName="text"
/>
<View
android:id="#+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="15dp"
android:layout_marginBottom="15dp"
android:elevation="0dp"
android:background="#color/grey"
/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
>
<ImageButton
android:id="#+id/fav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_star_black_24dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:padding="5dp"
android:background="?android:attr/selectableItemBackground"
android:tint="#9E9E9E"
/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="top"
android:id="#+id/snackbar">
</android.support.design.widget.CoordinatorLayout>
The textview doesnt animate to an edittext.
The explode animation appears.
Between activities the animation works.
Any suggestions how to fix?

GridView does not expand

I am kinda new in android and got such a problem, I am trying to use ExpandableHeightGridView for gridview inside scrollview, but layout doesn't render, some advice please.
It always gives me this error:
Exception raised during rendering: ScrollView can host only one direct child
ExpandableHeightGridView.class:
public class ExpandableHeightGridView extends GridView {
boolean expanded = false;
public ExpandableHeightGridView(Context context)
{
super(context);
}
public ExpandableHeightGridView(Context context, AttributeSet attrs)
{
super(context, attrs);
}
public ExpandableHeightGridView(Context context, AttributeSet attrs,
int defStyle)
{
super(context, attrs, defStyle);
}
public boolean isExpanded()
{
return expanded;
}
#Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
{
// HACK! TAKE THAT ANDROID!
if (isExpanded())
{
// Calculate entire height by providing a very large height hint.
// View.MEASURED_SIZE_MASK represents the largest height possible.
int expandSpec = MeasureSpec.makeMeasureSpec(MEASURED_SIZE_MASK,
MeasureSpec.AT_MOST);
super.onMeasure(widthMeasureSpec, expandSpec);
ViewGroup.LayoutParams params = getLayoutParams();
params.height = getMeasuredHeight();
}
else
{
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
public void setExpanded(boolean expanded)
{
this.expanded = expanded;
} }
layout.xml:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#fed70d"
android:orientation="horizontal">
<ImageView
android:id="#+id/iconBack"
android:layout_width="45dp"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:paddingBottom="16dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="16dp"
android:src="#drawable/icon_back_white" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="20dp"
android:text="Wishlist"
android:textColor="#ac920d"
android:textSize="24sp" />
<LinearLayout
android:id="#+id/myCart"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center|right"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="10dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/addedInCart"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="center|right"
android:src="#drawable/icon_menu_cart" />
<TextView
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginTop="5dp"
android:background="#drawable/icon_mycart_count"
android:gravity="center_horizontal|center"
android:text="2"
android:textColor="#ffffff"
android:textSize="10dp" />
</LinearLayout>
<TextView
android:id="#+id/myMoneyInMyPocket"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center|right"
android:layout_marginRight="10dp"
android:text="2000$"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#ad8c22" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#fed70d"
android:orientation="horizontal"
android:weightSum="5.0">
<LinearLayout
android:id="#+id/menuItemStores"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical"
android:paddingTop="8dp">
<ImageView
android:id="#+id/menuIconStores"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="center"
android:src="#drawable/icon_menu_logo" />
<TextView
android:id="#+id/menuTextStores"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Stores"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/menuItemInfo"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical"
android:paddingTop="8dp">
<ImageView
android:id="#+id/menuIconInfo"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="center"
android:src="#drawable/icon_menu_info" />
<TextView
android:id="#+id/menuTextInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Info"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1.0"
android:background="#drawable/selected_menu_background"
android:orientation="vertical"
android:paddingTop="8dp">
<ImageView
android:id="#+id/menuIconWishlist"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="center"
android:src="#drawable/icon_wishlist" />
<TextView
android:id="#+id/menuTextWishlist"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Wishlist"
android:textColor="#ffffff"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/menuItemAccount"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical"
android:paddingTop="8dp">
<ImageView
android:id="#+id/menuIconAccount"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="center"
android:src="#drawable/icon_menu_account" />
<TextView
android:id="#+id/menuTextAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Account"
android:textSize="14sp" />
</LinearLayout>
<LinearLayout
android:id="#+id/menuItemCart"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.0"
android:orientation="vertical"
android:paddingTop="8dp">
<ImageView
android:id="#+id/menuIconCart"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_gravity="center"
android:src="#drawable/icon_menu_cart" />
<TextView
android:id="#+id/menuTextCart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Cart"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
<View
android:id="#+id/dropShadow"
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#drawable/drop_shadow"
android:cacheColorHint="#f1e7dd"
android:paddingTop="8dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.example.utils.ExpandableHeightGridView
android:id="#+id/wishListGridView"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:columnWidth="80dp"
android:gravity="center"
android:horizontalSpacing="10dp"
android:isScrollContainer="false"
android:numColumns="2"
android:paddingBottom="#dimen/activity_horizontal_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:stretchMode="columnWidth"
android:verticalSpacing="10dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
This problem is discussed here.
Try adding one more LinearLayout inside your ScrollView as a direct child and put all other layouts/controls inside of the new LinearLayout.

Categories

Resources