即使我在primary_layout.xml中进行了滚动视图,表中的项也没有完全向下滚动。它只滚动到设备号。 请参阅以下代码。
TabFragment.java
public class TabFragment extends Fragment {
public static TabLayout tabLayout;
public static ViewPager viewPager;
public static int int_items = 3 ;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
/**
*Inflate tab_layout and setup Views.
*/
View x = inflater.inflate(R.layout.tab_layout,null);
tabLayout = (TabLayout) x.findViewById(R.id.tabs);
viewPager = (ViewPager) x.findViewById(R.id.viewpager);
/**
*Set an Apater for the View Pager
*/
viewPager.setAdapter(new MyAdapter(getChildFragmentManager()));
/**
* Now , this is a workaround ,
* The setupWithViewPager dose't works without the runnable .
* Maybe a Support Library Bug .
*/
tabLayout.post(new Runnable() {
@Override
public void run() {
tabLayout.setupWithViewPager(viewPager);
}
});
return x;
}
class MyAdapter extends FragmentPagerAdapter{
public MyAdapter(FragmentManager fm) {
super(fm);
}
/**
* Return fragment with respect to Position .
*/
@Override
public Fragment getItem(int position)
{
switch (position){
case 0 : return new PrimaryFragment();
case 1 : return new SocialFragment();
case 2 : return new UpdatesFragment();
}
return null;
}
@Override
public int getCount() {
return int_items;
}
/**
* This method returns the title of the tab according to the position.
*/
@Override
public CharSequence getPageTitle(int position) {
switch (position){
case 0 :
return "Info";
case 1 :
return "Details";
case 2 :
return "Summary";
}
return null;
}
}
}
tab_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:orientation="vertical"
android:layout_height="wrap_content">
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
app:tabGravity="fill"
app:tabMode="fixed"
android:background="#fff"
app:tabIndicatorColor="@color/orange"
app:tabSelectedTextColor="@android:color/background_dark"
app:tabTextColor="@android:color/background_dark"
android:layout_width="match_parent"
android:textAllCaps="false"
android:layout_height="wrap_content">
</android.support.design.widget.TabLayout>
<View
android:layout_width="match_parent"
android:background="#616161"
android:layout_height="1px"></View>
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</android.support.v4.view.ViewPager>
</LinearLayout>
primary_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView
android:id="@+id/scrollView"
android:scrollbars="none"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/border_box"
android:layout_margin="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="@string/faultcategory"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/supportlevel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/eventstatus"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/Servicelevel"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/user"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/Fromeventdate"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/ToEventDate"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/eventNo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/engineerName"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/eventtypes"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/employeeshift"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/hostName"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/extensionNo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@android:color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal">
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:text="@string/deviceNo"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@android:color/black"
android:textSize="15dp" />
<View
android:layout_width="1px"
android:layout_height="match_parent"
android:background="@android:color/black"/>
<TextView
android:layout_weight="1"
android:gravity="center|left"
android:paddingLeft="5dp"
android:layout_width="0dp"
android:layout_height="match_parent"
android:text="Abcsd"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textSize="15dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
答案 0 :(得分:1)
在primary_layout
中,在android:layout_weight="1"
窗口小部件中设置android:layout_height="0dp"
和ScrollView
。然后它应该完全滚动。之后,根据要求设置底部填充。