Fragment inside ViewPager doesn't scroll - android

I have an Activity that have an appBarLayout with a TabLayout that should cover the 2/5 of the screen, so it's a big AppBarLayout. I created it, made the tabLayout and configured the viewPager and it is working, but there are three with issues that I can't figure out how to resolve:
Without this app:layout_behavior="#string/appbar_scrolling_view_behavior" the viewpager shows beside the appBarLayout
Whenever I enter in any of the editTexts the AppBarLayout shows fullscreen.
The second fragment has big height and should scroll down, but the it doesn't.
Relevant code:
Activity with the appBarLayout and the viewPager
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/rootLayout"
android:fitsSystemWindows="true"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.AppBarLayout
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:minHeight="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
>
<TextView
android:id="#+id/title"
android:textSize="17sp"
android:text="#string/app_name"
android:textColor="#color/green_900"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.v7.widget.Toolbar>
<ImageView
android:id="#+id/img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="center"
android:src="#drawable/logo_home"
android:fitsSystemWindows="true"
/>
<TextView
android:id="#+id/txt_version"
android:text="#string/app_version"
android:textColor="#color/white"
android:textSize="10sp"
android:layout_below="#+id/img_logo"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
app:tabMode="fixed"
app:layout_collapseMode="pin"
app:tabIndicatorHeight="3dp"
app:tabIndicatorColor="#color/light_green_a700"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#color/white_background" />
</android.support.design.widget.CoordinatorLayout>
The second page (Tab) that should scroll:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:background="#color/white_background"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="23dp"
android:background="#color/white_background">
<Button
android:id="#+id/btn_facebook_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/facebook_register"
android:drawableLeft="#drawable/fb_logo"
android:textSize="15sp"
android:padding="5dp"
android:layout_marginLeft="11dp"
android:layout_marginRight="11dp"
android:textColor="#color/white"
android:background="#drawable/button_facebook_shape"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_marginTop="20dp"
android:id="#+id/white_line"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="0.5dp"/>
<View
android:background="#color/login_hint"
android:layout_width="match_parent"
android:layout_below="#+id/white_line"
android:layout_height="0.5dp"/>
<TextView
android:layout_marginTop="20dp"
android:textColor="#color/login_hint"
android:background="#color/white_background"
android:layout_width="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="o con tu mail..."/>
</RelativeLayout>
<EditText
android:id="#+id/edt_register_name"
android:layout_width="match_parent"
android:background="#drawable/edit_text_shape"
android:padding="20dp"
android:textSize="15sp"
android:maxLines="1"
android:inputType="textCapWords"
android:imeOptions="actionNext"
android:textColorHint="#color/login_hint"
android:hint="#string/txt_register_name"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/edt_register_lastname"
android:layout_marginTop="15dp"
android:padding="20dp"
android:textSize="15sp"
android:maxLines="1"
android:inputType="textCapWords"
android:imeOptions="actionNext"
android:background="#drawable/edit_text_shape"
android:layout_width="match_parent"
android:textColorHint="#color/login_hint"
android:hint="#string/txt_register_last_name"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/edt_register_email"
android:layout_marginTop="15dp"
android:padding="20dp"
android:textSize="15sp"
android:maxLines="1"
android:imeOptions="actionNext"
android:inputType="textEmailAddress"
android:background="#drawable/edit_text_shape"
android:layout_width="match_parent"
android:textColorHint="#color/login_hint"
android:hint="#string/txt_register_email"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/edt_register_pass"
android:layout_marginTop="15dp"
android:padding="20dp"
android:textSize="15sp"
android:maxLines="1"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:background="#drawable/edit_text_shape"
android:layout_width="match_parent"
android:textColorHint="#color/login_hint"
android:hint="#string/txt_register_pass"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/edt_register_pss_conf"
android:layout_marginTop="15dp"
android:padding="20dp"
android:textSize="15sp"
android:maxLines="1"
android:inputType="textPassword"
android:imeOptions="actionDone"
android:background="#drawable/edit_text_shape"
android:layout_width="match_parent"
android:textColorHint="#color/login_hint"
android:hint="#string/txt_register_pass_confirm"
android:layout_height="wrap_content" />
<Button
android:layout_marginTop="15dp"
android:id="#+id/btn_register_done"
android:text="#string/btn_register_done"
android:drawableLeft="#drawable/kick"
android:paddingLeft="30dp"
android:textColor="#color/white"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:textSize="15sp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/button_done_shape"/>
</LinearLayout>
</ScrollView>
The java code for the Activity and the viewPager
public class LoginRegisterActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
viewPager.setAdapter(new myFragmentPagerAdapter(getSupportFragmentManager(), LoginRegisterActivity.this));
TabLayout tabs = (TabLayout) findViewById(R.id.tabs);
tabs.setupWithViewPager(viewPager);
}
public class myFragmentPagerAdapter extends FragmentPagerAdapter {
final int PAGE_COUNT = 2;
private String tabTitles[] = new String[]{"Ingresar", "Registrarse"};
private Context context;
public myFragmentPagerAdapter(FragmentManager fm, Context context) {
super(fm);
this.context = context;
}
#Override
public int getCount() {
return PAGE_COUNT;
}
#Override
public Fragment getItem(int position) {
switch (position) {
case 0:
return LoginFragment.newInstance(position);
case 1:
return RegisterFragment.newInstance(position);
default:
return null;
}
}
#Override
public CharSequence getPageTitle(int position) {
// Generate title based on item position
return tabTitles[position];
}
}

Related

Fragment (Viewpager) inside NestedScrollView not loading

I have Fragment with layout of CoordinatorLayout Inside with NestedScrollView and inside nestedscrollview i have ViewPager and TabLayout with fragments. Tabs is visible but fragment related to tabs is not loading.
Layout
<?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"
android:clickable="true"
android:background="?android:attr/colorBackground"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<!--app:contentScrim="?attr/colorPrimary" -->
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/ViewPagerImages"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7"
android:scrollIndicators="top|right">
</android.support.v4.view.ViewPager>
<ProgressBar
android:layout_width="120dp"
android:layout_height="120dp"
android:id="#+id/Progress_Bar_Image"
android:layout_gravity="center_horizontal|center_vertical"
android:visibility="visible"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right|top"
android:layout_marginRight="30dp"
android:layout_marginTop="30dp"
android:background="#drawable/round_default"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:text="1"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="25sp"
android:text="/5"/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="200dp"
android:layout_gravity="bottom"
android:padding="15dp"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/unsa"
android:orientation="horizontal"
android:gravity="center">
<ImageView
android:id="#+id/user_S"
android:layout_width="25dp"
android:layout_height="25dp"
android:padding="10dp" />
<TextView
android:id="#+id/ViewPager_Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
app:layout_behavior="com.boysjoys.com.pro_working1.CustomClass.UserProfile_Behaviour"
android:textSize="35sp" />
<TextView
android:id="#+id/ViewPager_A"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Age"
/>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="New Delhi"
android:layout_below="#id/unsa"
android:layout_marginLeft="37dp"
android:id="#+id/ViewPager_City"
/>
<Button
android:id="#+id/Attached"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="#drawable/round_button"
android:layout_alignParentBottom="true"
android:elevation="14dp"
android:shadowColor="#A8A8A8"
android:shadowDx="0"
android:shadowDy="0"
android:shadowRadius="5"
android:text="WRITE ME"
android:textColor="#FFFFFF"
android:textSize="20sp" />
</RelativeLayout>
<View
android:id="#+id/fabBGLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/custom_transparent_color1"
android:visibility="gone"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabOne"
android:layout_gravity="bottom|end"
android:padding="12dp"
android:visibility="gone"
android:layout_marginBottom="90dp"
android:layout_marginRight="20dp"
android:layout_width="45dp"
android:layout_height="45dp" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabTwo"
android:padding="12dp"
app:fabSize="mini"
android:visibility="gone"
android:layout_gravity="bottom|end"
android:layout_marginBottom="90dp"
android:layout_marginRight="20dp"
android:layout_width="45dp"
android:layout_height="45dp" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabThree"
android:layout_gravity="bottom|end"
android:padding="12dp"
app:fabSize="mini"
android:visibility="gone"
android:layout_marginBottom="90dp"
android:layout_marginRight="20dp"
android:layout_width="45dp"
android:layout_height="45dp" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabMain"
android:padding="12dp"
android:layout_gravity="bottom|end"
android:layout_marginBottom="90dp"
android:layout_marginRight="20dp"
android:src="#drawable/com_facebook_tooltip_black_xout"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
// NESTED SCROLL VIEW WHERE THE PROBLEM ARISE
// TABLAYOUT IS VISIBLE BUT FRAGMENT IS NOT.
<android.support.v4.widget.NestedScrollView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/userProfile_NestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="13dp"
android:background="#android:color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/ScrollViewChild"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="15dp">
<!--To show tab on top of view pager-->
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMode="scrollable"
app:tabTextColor="#color/place_autocomplete_prediction_primary_text_highlight"
app:tabSelectedTextColor="#color/colorPrimary"
app:tabIndicatorColor="#color/colorPrimary"
android:id="#+id/userProfile_Viewpager_Tab">
</android.support.design.widget.TabLayout>
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/userProfile_Viewpager_Tab"
android:id="#+id/userProfile_Viewpager_ViewPager">
</android.support.v4.view.ViewPager>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
ViewPager Adapter
public class UserProfile_TabAdapter extends FragmentPagerAdapter {
String TAG = "###TabAdapter###";
Context context;
public UserProfile_TabAdapter(FragmentManager fm,Context context) {
super(fm);
this.context=context;
}
#Override
public Fragment getItem(int position) {
Fragment fragment = null;
Log.d(TAG," Positions "+position);
switch (position) {
case 0:
fragment = Fragment.instantiate(context,Info_fragment.class.getName());
break;
case 1:
Log.d(TAG, "User Photos Running");
fragment = Fragment.instantiate(context,Photo_fragment.class.getName());
break;
case 2:
Log.d(TAG, "User Connections Running");
fragment = Fragment.instantiate(context,Connections_fragment.class.getName());
break;
}
return fragment;
}
#Override
public int getCount() {
return 3;
}
#Override
public CharSequence getPageTitle(int position) {
switch (position){
case 0:
return "About";
case 1:
return "Photo";
case 2:
return "Connections";
}
return null;
}
}
Fragment Where i try to load fragment into viewpager
//NESTED SCROLL VIEW TAB LAYOUT AND VIEW PAGER
userInfo_ViewPager=(ViewPager) view.findViewById(R.id.userProfile_Viewpager_ViewPager);
UserProfile_TabAdapter userProfile_tabAdapter=new UserProfile_TabAdapter(getChildFragmentManager(),getActivity());
userInfo_ViewPager.setAdapter(userProfile_tabAdapter);
tabLayout=(TabLayout) view.findViewById(R.id.userProfile_Viewpager_Tab);
tabLayout.setupWithViewPager(userInfo_ViewPager);
Fragment to load into viewpager
public class Info_fragment extends Fragment {
public static final String TAG="### INFO ####";
#Nullable
#Override
public View onCreateView(LayoutInflater inflater, #Nullable ViewGroup container, Bundle savedInstanceState) {
View view=inflater.inflate(R.layout.userprofile_photos,container,false);
//Above Layout only have colorful background to match parent.
return view;
}
}
Try this
NestedScrollView scrollView = (NestedScrollView) findViewById (R.id.userProfile_NestedScrollView);
scrollView.setFillViewport (true);
Add This Line in your in NestedScrollView
android:fillViewport="true"
// your appBar layout height is match_parent change it with wrap_content
<android.support.design.widget.AppBarLayout
android:id="#+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
The problem is your view pager height. Just make some height then your page will be visible.
Example:
<android.support.v4.view.ViewPager
android:id="#+id/userProfile_Viewpager_ViewPager"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_below="#id/userProfile_Viewpager_Tab">
</android.support.v4.view.ViewPager>
You have to find the solution why the view pager not taken the height
or
NestedScrollView scrollView = (NestedScrollView) findViewById (R.id.userProfile_NestedScrollView);
scrollView.setFillViewport (true);
I have same issue and the best solution is to set hight for your viewpager
Example:
android:layout_height="500dp"

RecyclerView not showing up properly (scrunched up)

I've been trying to implement multiple RecyclerView within a layout that is part of a collapsing tab. However, my RecyclerView hasn't been working and I don't know what I did wrong in my code. Please help me!
Here is the Github Link: github.com/arxbombus/RecipeDetails
Here is the desired view: image
Here is what I'm getting for some reason: image
As you can see, everything is all scrunched up. :(
Below I've included the layouts for my MainActivity and also the Java files for my Adapters.
Here is my activity_main.xml
<?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"
android:id="#+id/coordinatorLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="#+id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="400dp"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapsingToolbarLayout"
android:layout_width="match_parent"
android:layout_height="400dp"
app:title="Some Randome Recipe"
app:titleEnabled="true"
app:contentScrim="?attr/colorPrimary"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/ivParallax"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="#drawable/food"
app:layout_collapseMode="parallax"
app:layout_collapseParallaxMultiplier="0.7" />
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/nestedScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtAbout"
android:text="About this recipe"
android:textStyle="bold"
android:textSize="13sp"
android:padding="15dp"
android:layout_marginBottom="-25dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtRecipeDescription"
android:text="#string/recipe_description"
android:padding="15dp"
android:layout_marginBottom="-5dp"
android:textSize="12sp"/>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/colorDivider"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtInfo"
android:text="Info"
android:textStyle="bold"
android:textSize="13sp"
android:padding="15dp"
android:layout_marginBottom="-20dp"
android:layout_marginTop="-5dp"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvRecipeInfo"
android:layout_width="match_parent"
android:layout_height="75dp"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp"></android.support.v7.widget.RecyclerView>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/colorDivider"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtIngredient"
android:text="Ingredients"
android:textStyle="bold"
android:textSize="13sp"
android:padding="15dp"
android:layout_marginBottom="-20dp"
android:layout_marginTop="-5dp"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvRecipeIngredient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp"></android.support.v7.widget.RecyclerView>
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/colorDivider"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
walking
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/txtProcedures"
android:text="Procedures"
android:textStyle="bold"
android:textSize="13sp"
android:padding="15dp"
android:layout_marginBottom="-20dp"
android:layout_marginTop="-5dp"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvRecipeProcedure"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp"></android.support.v7.widget.RecyclerView>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
And my CardView
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/recipeInfoCards"
android:layout_width="81dp"
android:layout_height="75dp"
app:cardCornerRadius="6dp"
android:elevation="15dp"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorRecipeInfoCardBG"
android:padding="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/txtRecipeInfoCardTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cooking Time:"
android:textSize="11sp"
android:textColor="#android:color/black"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_marginTop="5dp"
/>
<TextView
android:id="#+id/txtRecipeInfoCardDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="20 Minutes"
android:textSize="11sp"
android:textColor="#color/colorTextSecondary"
android:layout_gravity="center_horizontal"
android:gravity="center"/>
</LinearLayout>
</android.support.v7.widget.CardView>
And here are my MainActivity and Adapters respectiviely
public class MainActivity extends AppCompatActivity {
ArrayList < Recipe > recipeData;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_main);
recipeData = new ArrayList < Recipe > ();
createData();
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
RecyclerView recipeInfoCardRV = (RecyclerView) findViewById(R.id.rvRecipeInfo);
recipeInfoCardRV.setHasFixedSize(true);
recipeInfoCardRV.setNestedScrollingEnabled(false);
RecipeInfoAdapter recipeInfoAdapter = new RecipeInfoAdapter(this, recipeData);
recipeInfoCardRV.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
recipeInfoCardRV.setAdapter(recipeInfoAdapter);
RecyclerView recipeIngredientRV = (RecyclerView) findViewById(R.id.rvRecipeIngredient);
recipeIngredientRV.setHasFixedSize(true);
recipeIngredientRV.setNestedScrollingEnabled(false);
recipeIngredientRV.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
RecipeIngredientAdapter recipeIngredientAdapter = new RecipeIngredientAdapter(this, recipeData);
recipeIngredientRV.setAdapter(recipeIngredientAdapter);
}
public void createData() {
ArrayList < RecipeInfoCard > recipeInfoCards = new ArrayList < RecipeInfoCard > ();
recipeInfoCards.add(new RecipeInfoCard("Cooking Time", "20 Minutes"));
recipeInfoCards.add(new RecipeInfoCard("Calories", "3501"));
recipeInfoCards.add(new RecipeInfoCard("Procedures", "Three"));
ArrayList < RecipeIngredient > recipeIngredients = new ArrayList < RecipeIngredient > ();
for (int i = 1; i <= 10; i++) {
recipeIngredients.add(new RecipeIngredient("Ingredient " + i, String.valueOf(i), "grams"));
}
Recipe dm = new Recipe(recipeInfoCards, recipeIngredients);
recipeData.add(dm);
}
}
My adapter for my CardView
public class RecipeInfoAdapter extends RecyclerView.Adapter < RecipeInfoAdapter.RecipeInfoCardItemRowHolder > {
private Context mContext;
private ArrayList < Recipe > recipeData;
public RecipeInfoAdapter(Context mContext, ArrayList < Recipe > recipeData) {
this.mContext = mContext;
this.recipeData = recipeData;
}
#Override
public RecipeInfoCardItemRowHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.recipe_info_card_view, null);
return new RecipeInfoCardItemRowHolder(v);
}
#Override
public void onBindViewHolder(RecipeInfoCardItemRowHolder recipeInfoCardItemRowHolder, int position) {
Recipe recipe = recipeData.get(position);
recipeInfoCardItemRowHolder.infoCardTitle.setText(recipe.getRecipeInfoCards().get(position).getRecipeInfoCardTitle());
recipeInfoCardItemRowHolder.infoCardDescription.setText(recipe.getRecipeInfoCards().get(position).getRecipeInfoCardDescription());
}
#Override
public int getItemCount() {
return (null != recipeData ? recipeData.size() : 0);
}
public class RecipeInfoCardItemRowHolder extends RecyclerView.ViewHolder {
protected TextView infoCardTitle;
protected TextView infoCardDescription;
public RecipeInfoCardItemRowHolder(View view) {
super(view);
this.infoCardTitle = (TextView) view.findViewById(R.id.txtRecipeInfoCardTitle);
this.infoCardDescription = (TextView) view.findViewById(R.id.txtRecipeInfoCardDescription);
}
}
}
I didn't put all my code here because I think the question is long enough but I would really appreciate if someone helped me. Thank you!
Try to change your rvRecipeInfo RecyclerView height.. becasue your hardicoading it to 75 dp which is wrong.
<android.support.v7.widget.RecyclerView
android:id="#+id/rvRecipeInfo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:orientation="horizontal"
android:padding="15dp"></android.support.v7.widget.RecyclerView>
similer to cardview as well
< ?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/recipeInfoCards"
android:layout_width="100dp"
android:layout_height="75dp"
app:cardCornerRadius="6dp"
android:elevation="15dp"
android:orientation="horizontal"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#color/colorRecipeInfoCardBG"
android:padding="10dp"
android:orientation="vertical">
<TextView
android:id="#+id/txtRecipeInfoCardTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Cooking Time:"
android:textSize="11sp"
android:textColor="#android:color/black"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_marginTop="5dp"
/>
<TextView
android:id="#+id/txtRecipeInfoCardDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="20 Minutes"
android:textSize="11sp"
android:textColor="#color/colorTextSecondary"
android:layout_gravity="center_horizontal"
android:gravity="center"/>
</LinearLayout>
</android.support.v7.widget.CardView>

How to disable nested scrolling of viewpager within the nestedscrollview in android activity?

This is what my nestedscrollview looks like
This is where my viewpager, along with other views and layouts are placed inside that nestedscrollview
Now issue is that the viewpager, which is swiping fragments of recyclerviews left and right, is not scrolling down along with the nestedscrollview. Activity scrolls only upto the tab layout, as shown in the second picture. Viewpager scrolls nested. Can you PLEASE solve this problem?
This is how my main activity's layout looks like:
<?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"
android:layout_height="match_parent"
android:id="#+id/main_profile"
android:layout_width="match_parent"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="430dp"
android:id="#+id/app_bar"
android:fitsSystemWindows="true"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/collapsing_toolbar"
android:fitsSystemWindows="true"
app:layout_scrollFlags="scroll|enterAlwaysCollapsed">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/profile_image"
android:scaleType="centerCrop"
android:fitsSystemWindows="true"
app:layout_collapseMode="parallax"
android:src="#drawable/sample_image"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="240dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="William Stevenson"
android:textSize="24sp"
android:gravity="center"
android:textColor="#f0f0f0"
android:id="#+id/userName" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Graphic Designer. Freelancer"
android:textSize="16sp"
android:gravity="center"
android:textColor="#f0f0f0"
android:layout_below="#id/userName"
android:id="#+id/tagline"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_below="#id/tagline"
android:layout_marginTop="48dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp">
<Button
android:layout_width="wrap_content"
android:layout_height="48dp"
android:paddingLeft="48dp"
android:paddingRight="48dp"
android:textSize="12sp"
android:textColor="#f0f0f0"
android:text="Follow"
android:layout_centerHorizontal="true"
android:id="#+id/follow"
android:background="#drawable/follow_button_flat"/>
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_toLeftOf="#id/follow"
android:layout_centerVertical="true"
android:id="#+id/voiceCallMessage"
android:src="#drawable/ic_mic_none_white_48dp"
android:layout_marginRight="32dp" />
<ImageView
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_toRightOf="#id/follow"
android:layout_centerVertical="true"
android:id="#+id/videoCallMessage"
android:layout_marginLeft="32dp"
android:src="#drawable/ic_videocam_white_48dp" />
</RelativeLayout>
</RelativeLayout>
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
app:rippleColor="#303030"
app:backgroundTint="#3292D3"
app:layout_anchor="#id/app_bar"
android:src="#drawable/ic_bubble_chart_white_48dp"
app:fabSize="normal"
app:layout_anchorGravity="bottom|right"/>
<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"
android:id="#+id/nestedScrollView">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="32dp"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp"
android:id="#+id/profileStats"
android:orientation="horizontal">
...
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="256dp"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="48dp"
android:id="#+id/imagesAndVideos"
android:layout_below="#id/profileStats">
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/frame_layout_corner"
android:clickable="false">
...
</TableLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="800+ Images"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#f0f0f0"
android:id="#+id/imagesTag"
android:textSize="18sp" />
<Button
android:layout_width="wrap_content"
android:layout_height="32dp"
android:paddingLeft="32dp"
android:paddingRight="32dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:text="Show All"
android:gravity="center"
android:id="#+id/showAll"
android:background="#drawable/follow_button_flat"
android:textColor="#f0f0f0"
android:textSize="14sp"/>
</LinearLayout>
</FrameLayout>
<com.gigamole.navigationtabstrip.NavigationTabStrip
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_marginLeft="48dp"
android:layout_marginRight="48dp"
app:nts_animation_duration="300"
app:nts_factor="1.2"
app:nts_size="16dp"
app:nts_type="line"
app:nts_titles="#array/posts_and_friends"
android:layout_below="#id/imagesAndVideos"
android:layout_marginTop="48dp"
android:id="#+id/post_and_friends_nav_strip"/>
<!--Problem is here-->
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/posts_friends_view_pager"
android:layout_below="#id/post_and_friends_nav_strip"
android:layout_marginTop="16dp"/>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>
This is what my both the fragments looks like:
Fragment 1's layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainPosts"
android:layout_height="wrap_content"/>
Fragment 2's layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/friends"
android:layout_height="wrap_content"/>
Yeah, almost similar.
Edit: I've tried setting android:nestedScrollingEnabled to false in the recyclerview. But It just stops scrolling of the viewpager. Activity can't be scrolled down below the tab layout of the viewpager. Viewpager remains below the phone screen.
Edit 2: This is what my main activity looks like:
public class Profile extends AppCompatActivity {
TextView userName, tagline, followers, followersTag, points, pointsTag, following, followingTag, imagesTag;
ImageView userImage, sample1, sample2, sample3, sample4;
Button showAllImages;
Typeface robotoRegular, robotoLight;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.content_profile);
initActivity();
ViewPager postsAndFriendsViewPager = (ViewPager) findViewById(R.id.posts_friends_view_pager);
FragmentManager fragmentManager = getSupportFragmentManager();
ViewPagerAdapterPostsFriends viewPagerAdapterPostsFriends = new ViewPagerAdapterPostsFriends(fragmentManager);
postsAndFriendsViewPager.setAdapter(viewPagerAdapterPostsFriends);
NavigationTabStrip navigationTabStrip = (NavigationTabStrip) findViewById(R.id.post_and_friends_nav_strip);
navigationTabStrip.setTabIndex(0);
navigationTabStrip.setStripColor(Color.TRANSPARENT);
navigationTabStrip.setActiveColor(Color.RED);
navigationTabStrip.setInactiveColor(Color.DKGRAY);
navigationTabStrip.setViewPager(postsAndFriendsViewPager);
}
class ViewPagerAdapterPostsFriends extends FragmentStatePagerAdapter
{
ViewPagerAdapterPostsFriends(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
if(position == 0)
return Posts.init();
return ProfileFriends.init();
}
#Override
public int getCount() {
return 2;
}
}
private void initActivity()
{
userImage = (ImageView) findViewById(R.id.profile_image);
sample1 = (ImageView) findViewById(R.id.sample1);
sample2 = (ImageView) findViewById(R.id.sample2);
sample3 = (ImageView) findViewById(R.id.sample3);
sample4 = (ImageView) findViewById(R.id.sample4);
userName = (TextView) findViewById(R.id.userName);
imagesTag = (TextView) findViewById(R.id.imagesTag);
tagline = (TextView) findViewById(R.id.tagline);
points = (TextView) findViewById(R.id.points);
pointsTag = (TextView) findViewById(R.id.pointsTag);
followers = (TextView) findViewById(R.id.followers);
followersTag = (TextView) findViewById(R.id.followersTag);
following = (TextView) findViewById(R.id.following);
followingTag = (TextView) findViewById(R.id.followingTag);
showAllImages = (Button) findViewById(R.id.showAll);
robotoLight = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Light.ttf");
robotoRegular = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf");
Picasso.with(this).load(R.drawable.sample_image).transform(new BrightnessFilterTransformation(this, -0.1f)).into(userImage);
userName.setTypeface(robotoLight);
imagesTag.setTypeface(robotoLight);
tagline.setTypeface(robotoLight);
points.setTypeface(robotoRegular);
pointsTag.setTypeface(robotoRegular);
followers.setTypeface(robotoRegular);
followersTag.setTypeface(robotoRegular);
following.setTypeface(robotoRegular);
followingTag.setTypeface(robotoRegular);
showAllImages.setTypeface(robotoLight);
}
}

gravity bottom for viewpager children

Trying to push TextViews to the bottom of the ViewPager container. Right now the TextViews only stay on the top, both when I wrap_content and match_parent. Here's the XML:
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_above="#+id/layout_view_pager_navigation">
<TextView
android:id="#+id/string_main_intro_1"
android:text="#string/string_main_intro_1"
android:background="#color/buttonColor"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/textPrimary"
android:textSize="22sp"
android:textAlignment="center"
android:gravity="bottom"/>
<TextView
android:id="#+id/string_main_intro_2"
android:text="#string/string_main_intro_2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/textPrimary"
android:textSize="22sp"
android:textAlignment="center"
android:gravity="bottom"/>
<TextView
android:id="#+id/string_main_intro_3"
android:text="#string/string_main_intro_3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/textPrimary"
android:textSize="18sp"
android:textAlignment="center"
android:gravity="bottom"/>
<TextView
android:id="#+id/string_main_intro_4"
android:text="#string/string_main_intro_4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#color/textPrimary"
android:textSize="18sp"
android:textAlignment="center"
android:gravity="bottom"/>
</android.support.v4.view.ViewPager>
I would suggest creating a different layout for your TextViews like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/my_tvs"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom"
>
<TextView
android:id="#+id/string_main_intro_1"
android:text="#string/string_main_intro_1"
android:background="#color/buttonColor"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/textPrimary"
android:textSize="22sp"
android:textAlignment="center"
/>
<TextView
android:id="#+id/string_main_intro_2"
android:layout_below="#+id/string_main_intro_1"
android:text="#string/string_main_intro_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/textPrimary"
android:textSize="22sp"
android:textAlignment="center"
/>
<TextView
android:id="#+id/string_main_intro_3"
android:layout_below="#+id/string_main_intro_2"
android:text="#string/string_main_intro_3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/textPrimary"
android:textSize="18sp"
android:textAlignment="center"
/>
<TextView
android:id="#+id/string_main_intro_4"
android:layout_below="#+id/string_main_intro_3"
android:text="#string/string_main_intro_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#color/textPrimary"
android:textSize="18sp"
android:textAlignment="center"
/>
</RelativeLayout>
Then your ViewPager layout would look like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_above="#+id/layout_view_pager_navigation">
</RelativeLayout>
Then in your Viewpager.java you can add the views:
ViewPager vpp = (ViewPager) findViewById(R.id.pager);
this.addPages(vpp);
RelativeLayout relative = (RelativeLayout) findViewById(R.id.my_tvs);
relative.setGravity(RelativeLayout.ALIGN_BOTTOM);
//ADD ALL PAGES TO TABLAYOUT
private void addPages(ViewPager pager){
MyFragPagerAdapter adapter=new
MyFragPagerAdapter(getSupportFragmentManager());
adapter.addPage(new MyCustomView()); <----------- This will be the layout with your textViews
You will also need a adapter to add the views--
public class MyFragPagerAdapter extends FragmentPagerAdapter {
ArrayList<Fragment> pages=new ArrayList<>();
public MyFragPagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
return pages.get(position);
}
#Override
public int getCount() {
return pages.size();
}
//ADD A PAGE
public void addPage (Fragment f){
pages.add(f);
}
//SET TITLE FOR TAB
#Override
public CharSequence getPageTitle(int position) {
return pages.get(position).toString();
}
}

Getting NullPointerException when adding toolbar

Getting NullPointerExceptionwhen trying to add a toolbar which is been defined in a layout file other than main design xml file. I keep getting the following error:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.support.v7.widget.Toolbar.findViewById(int)' on a null object reference
Here is my code
public class History_List_Details_Fragment extends Fragment {
Histroy_List_Model histroyListModel;
public History_List_Details_Fragment() {
}
#Override
public void onCreate(#Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
histroyListModel = getArguments().getParcelable("historydetail");
String title=histroyListModel.getShared_title();
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
super.onCreate(savedInstanceState);
View rootView = inflater.inflate(R.layout.history_list_details_fragment, container, false);
Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.app_bar);
initializeListnersForToolbar(toolbar);
initializeViews(rootView);
return rootView;
}
private void initializeViews(View rootView) {
TextView titleText = (TextView) rootView.findViewById(R.id.txtTitle);
titleText.setText(histroyListModel.getShared_title());
TextView messageTExt = (TextView) rootView.findViewById(R.id.txtMessage);
titleText.setText(histroyListModel.getShared_message());
}
private void initializeListnersForToolbar(Toolbar toolbar){
((TextView) toolbar.findViewById(R.id.tool_bar_text_head)).setText(getResources().getString(R.string.friends));
((ImageView) toolbar.findViewById(R.id.tool_bar_back_arrow)).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Fragment fragment=new History_List_Fragment();
Utilities.getInstance(getActivity()).change_HomPage_Fragment(
fragment, "History_List_Fragment", getActivity());
}
});
}
}
History_List_Details_Fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title"
android:id="#+id/txtTitle"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Message"
android:id="#+id/txtMessage"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Duration"
android:id="#+id/txtDuration"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/lstMembers"></ListView>
</LinearLayout>
</LinearLayout>
How can I fix this error?
Add Toolbar in "history_list_details_fragment" with id "app_bar"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:id="#+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
local:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
local:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="68dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Title"
android:id="#+id/txtTitle"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Message"
android:id="#+id/txtMessage"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="70dp"
android:orientation="horizontal"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Duration"
android:id="#+id/txtDuration"
android:layout_gravity="center" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:id="#+id/lstMembers"></ListView>
</LinearLayout>
The error states clearly. Inside history_list_details_fragment.xml there is no Toolbar. Try to add it.
Or more probably the Toolbar is in you Activity layout, so init it inside Activity.

Categories

Resources