0
I have a ViewPage
that does not work the android:layout_height="fill_parent"
, shows nothing on the screen, but if I determine an ex value: android:layout_height="500dp"
the determined height appears.
.xml
<RelativeLayout
android:id="@+id/main_layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.widget.TabLayout
android:id="@+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:elevation="6dp"
android:minHeight="?attr/actionBarSize"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"/>
<android.support.v4.view.ViewPager
android:id="@+id/page"
android:layout_width="match_parent"
android:layout_height="fill_parent" <--não trabalha
android:layout_below="@id/tab_layout" />
</RelativeLayout>
.java
public class AlterarOsFragment extends Fragment implements View.OnClickListener {
public static final String TAG = "";
DataBaseHandler db;
int numeroOs;
public AlterarOsFragment(int numeroOs) {
this.numeroOs = numeroOs;
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_alterar_os, container, false);
db = new DataBaseHandler(getActivity());
TabLayout tabLayout = (TabLayout) rootView.findViewById(R.id.tab_layout);
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.informacoes)));
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.servicos)));
tabLayout.addTab(tabLayout.newTab().setText(getResources().getString(R.string.orcamento)));
tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);
tabLayout.setTabMode(TabLayout.MODE_SCROLLABLE);
final ViewPager viewPager = (ViewPager) rootView.findViewById(R.id.page);
final PagerAdapter adapter = new TabAdapter(getActivity().getSupportFragmentManager(), tabLayout.getTabCount(), numeroOs);
viewPager.setAdapter(adapter);
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
return rootView;
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
}
@Override
public void onDetach() {
super.onDetach();
}
@Override
public void onClick(View view) {
}
}
What’s inside that one
TabAdapter
? From what I understand, you’re creating aViewPager
within aFragment
right? How is your xml view configured within Tabadapter?– viana