0
プロファイルのtablayoutフラグメントを作成しました。子タブからTabLayoutの値を設定する方法
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/layout"
layout="@layout/common_act" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color5"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="@dimen/medium">
<RelativeLayout
android:id="@+id/layoutPic"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/profilePic"
android:layout_width="@dimen/size_profile_pic"
android:layout_height="@dimen/size_profile_pic"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:gravity="center"
android:scaleType="fitCenter"
android:src="@drawable/img_profile" />
<TextView
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/profilePic"
android:layout_marginTop="@dimen/gap_medium"
android:background="@null"
android:gravity="center"
android:hint="@string/first_name"
android:lines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:textColor="@color/veryDarkGrey"
android:textColorHint="@color/darkGrey"
android:textSize="@dimen/normal"
app:font="@{@string/font_roboto_bold}" />
<TextView
android:id="@+id/mobile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/name"
android:layout_marginTop="@dimen/gap_small"
android:background="@null"
android:gravity="center"
android:hint="@string/mobile_number"
android:lines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:textColor="@color/veryDarkGrey"
android:textColorHint="@color/darkGrey"
android:textSize="@dimen/normal"
app:font="@{@string/font_roboto_bold}" />
<TextView
android:id="@+id/type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/mobile"
android:layout_marginTop="@dimen/gap_small"
android:background="@null"
android:gravity="center"
android:hint="@string/mobile_number"
android:lines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:textColor="@color/veryDarkGrey"
android:textColorHint="@color/darkGrey"
android:textSize="@dimen/normal"
app:font="@{@string/font_roboto_bold}" />
</RelativeLayout>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gap_small"
android:background="@null"
android:gravity="center"
android:hint="Complete your profile "
android:lines="1"
android:paddingLeft="5dp"
android:singleLine="true"
android:textColor="@color/veryDarkGrey"
android:textColorHint="@color/darkGrey"
android:textSize="@dimen/normal"
app:font="@{@string/font_roboto_bold}" />
<com.xx.xx.ui.widget.SeekBarWithLabel
android:id="@+id/seekBarCustomer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:performanceProgress="20" />
</LinearLayout>
<android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/color3"
app:tabGravity="fill"
app:tabIndicatorHeight="4dp"
app:tabMode="fixed"
app:tabSelectedTextColor="@color/colorAccent" />
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</LinearLayout>
</ScrollView>
</LinearLayout>
以下のようなこのTabLayoutは、それから私は、プロファイルとワークショップとして、この のための2つの断片を作成しました。
は、それから私は、私は、レイアウトやクラスを作成している賢明枚この
public class ProfileFragment extends BaseFragment {
private MyprofileFragBinding mBinding;
public static ProfileFragment newInstance() {
return new ProfileFragment();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
mBinding = DataBindingUtil.inflate(inflater, R.layout.myprofile_frag, container, false);
mBinding.tabs.setupWithViewPager(mBinding.viewpager);
setupViewPager(mBinding.viewpager);
mBinding.layout.navMenu.setOnClickListener(view -> openTradeDrawer());
return mBinding.getRoot();
}
private void setupViewPager(ViewPager viewPager) {
ViewPagerAdapter adapter = new ViewPagerAdapter(getChildFragmentManager());
adapter.addFragment(new ProfileViewFragment(), getString(R.string.profile_view));
adapter.addFragment(new WorkShopFragment(), getString(R.string.workshop_profile));
viewPager.setAdapter(adapter);
}
}
のような主要なフラグメントを作成しました。 ここにプロファイル画像とテキストビューがメインのtablayoutに追加されました
最初の子フラグメントの中に私はAPIを呼び出しています。どうすれば画像と詳細をtablayoutに設定できますか?あなたのレイアウトXMLで
は、スクロール可能なレイアウトとして作成することが可能ですか? – CarinaMj
@CarinaMj私はちょうど私の答えを編集しました。 – Benjamin
画像全体にスクロールビューを追加することは可能ですか? – CarinaMj