How to implament "Parallax Animations" http://imgur.com/ah4l5oj.gif
if my scollable view (listview and scrollview) are placed inside fragments in viewpager?
MainLayout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/header_holder"
android:layout_width="match_parent"
android:layout_height="#dimen/video_holder_size"
android:background="#color/dark_gray">
<ImageView
android:id="#+id/im_photo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<TextView
android:id="#+id/tv_artist_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="16dip"
android:layout_marginLeft="16dip"
android:fontFamily="sans-sarif"
android:text="#string/artist_bio"
android:textColor="#color/white"
android:textSize="25sp" />
</RelativeLayout>
<com.astuetz.PagerSlidingTabStrip
android:id="#+id/tabs"
xmlns:slider="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="#dimen/controll_size"
slider:pstsIndicatorHeight="0dip"
slider:pstsPaddingMiddle="true"
slider:pstsTextAllCaps="true"
slider:pstsTextColorSelected="#color/white" />
<android.support.v4.view.ViewPager
android:id="#+id/video_body_pager"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:animationCache="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="#drawable/shadow_concierge_list_upper"
android:gravity="left|center_vertical"
android:orientation="horizontal">
<ImageButton
android:id="#+id/ibtn_back"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="8dip"
android:background="#drawable/ibtn_transparent"
android:padding="8dip"
android:src="#drawable/ic_action_back" />
</LinearLayout>
I tried to change view size by setting LayoutParams according to scroll delta, by performance is very poor
relatedHeight -= dY;// dY is a scroll delta
Log.e(getClass().getSimpleName(),"height "+relatedHeight+", dY "+dY);
if(relatedHeight < 0){
relatedHeight = 0;
} else if(relatedHeight > originalHeight){
relatedHeight = originalHeight;
} else{
LinearLayout.LayoutParams params =
(LinearLayout.LayoutParams) headerHolder.getLayoutParams();
params.height = (int) relatedHeight;
headerHolder.setLayoutParams(params);
}
I solved it using observableListview , otto bus and ViewHelper.
In pager fragment, I attach list.setScrollViewCallbacks(this); to my list.
In callback I pass offset to Bus
#Override
public void onScrollChanged(int scrollY, boolean firstScroll, boolean dragging){
BusProvider.getInstance().post(new ScrollOffset(0, scrollY));
}
#Override
public void onDownMotionEvent(){
}
#Override
public void onUpOrCancelMotionEvent(ScrollState scrollState){
}
In main fragment, I use viewhelper to translate header and viewpager
#Subscribe
public void moveHeader(ScrollOffset event){
ViewHelper.setTranslationY(headerHolder, -event.getY() / 2);
ViewHelper.setTranslationY(pager,headerHolder.getHeigh() -event.getY()/2);
int baseColor = getResources().getColor(R.color.dark_gray);
float alpha = Math.min(1, (float) event.getY()*10 / (originalHeight ));
appBarHolder.setBackgroundColor(ScrollUtils.getColorWithAlpha(alpha, baseColor));
}
Related
My Fragment is taking so much time in update layout It is because of a lot of code in fragment how to resolve this please help me
<?xml version="1.0" encoding="utf-8"?>
<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">
<data>
</data>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/lyttabs"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_marginRight="20dp"
android:layout_marginLeft="20dp"
android:gravity="center"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.bugfree.caviar.fonts.BabesNeueProBold
android:textStyle="bold"
android:layout_weight="1"
android:textColor="#color/black_text"
android:textSize="30dp"
android:layout_width="0dp"
android:text="My Events That I am..."
android:layout_height="wrap_content" />
<ImageView
android:id="#+id/btn_plus"
android:src="#drawable/plus"
android:layout_width="20dp"
android:layout_height="20dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabLayout
app:tabIndicatorColor="#color/button_red_back"
android:id="#+id/tabs"
android:layout_marginTop="15dp"
app:tabBackground="#drawable/tab_indicator_color"
app:tabTextAppearance="#style/MyCustomTextAppearance"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed" />
<androidx.viewpager.widget.ViewPager
android:layout_marginTop="30dp"
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</LinearLayout>
</LinearLayout>
<LinearLayout android:id="#+id/lytCreateEvent"
android:visibility="gone"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".activity.CreateEvent">
<ImageView
android:layout_marginEnd="15dp"
android:layout_marginStart="15dp"
android:layout_marginTop="30dp"
android:id="#+id/imgBack"
android:src="#drawable/back_black"
android:layout_width="20dp"
android:layout_height="20dp" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_marginEnd="15dp"
android:layout_marginStart="15dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp">
<com.bugfree.caviar.fonts.BabesNeueProBold
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Create event"
android:textColor="#color/black"
android:textSize="30dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:orientation="vertical">
<com.bugfree.caviar.fonts.BabesNeueProBoldRegular
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Event title" />
<EditText
android:singleLine="true"
android:paddingStart="15dp"
android:layout_marginTop="10dp"
android:textColorHint="#color/black"
android:background="#drawable/edit_back"
android:id="#+id/edtEventTitle"
android:textSize="18dp"
android:layout_gravity="center"
android:hint="Beach Yoga!"
android:layout_width="match_parent"
android:layout_height="50dp" />
</LinearLayout>
<LinearLayout
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.bugfree.caviar.fonts.BabesNeueProBoldRegular
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Event type" />
</LinearLayout>
<RelativeLayout
android:layout_marginTop="10dp"
android:layout_gravity="center"
android:gravity="center"
android:background="#drawable/edit_back"
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal">
<com.bugfree.caviar.fonts.BabesNeueProBoldRegular
android:layout_centerVertical="true"
android:paddingStart="15dp"
android:layout_width="wrap_content"
android:textColor="#color/black"
android:layout_height="wrap_content"
android:text="Business"
android:textSize="18dp" />
<ImageView
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_marginEnd="15dp"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_alignParentEnd="true"
android:src="#drawable/down_arrow" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<com.bugfree.caviar.fonts.BabesNeueProBoldRegular
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Event description" />
<com.bugfree.caviar.fonts.BabesNeueProBoldRegular
android:layout_marginEnd="15dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:text="94/300" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/custombutton_border_edittext"
android:orientation="vertical">
<EditText
android:textSize="18dp"
android:id="#+id/edtDescription"
android:textColorHint="#color/black_text_new"
android:padding="10dp"
android:layout_gravity="start"
android:gravity="start"
android:hint="Beach yoga with Alissia is a lifestyle focused on health,
wellness, and self-care through the practice of"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#android:color/transparent" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp">
<ImageView
android:layout_marginEnd="10dp"
android:layout_centerVertical="true"
android:tint="#color/black"
android:layout_alignParentEnd="true"
android:src="#drawable/down_arrowsmall"
android:layout_width="10dp"
android:layout_height="10dp" />
</RelativeLayout>
<EditText
android:paddingLeft="10dp"
android:layout_gravity="start"
android:gravity="start"
android:id="#+id/edtSplReq"
android:layout_width="match_parent"
android:layout_marginTop="15dp"
android:layout_height="100dp"
android:singleLine="true"
android:padding="10dp"
android:background="#drawable/lay_without_border"
android:hint="Add a special request[optional]"
android:textColorHint="#848484"
android:textSize="18dp" />
<Button
android:outlineProvider="bounds"
android:stateListAnimator="#null"
style="?android:attr/borderlessButtonStyle"
android:layout_marginBottom="35dp"
android:id="#+id/btnSubmit"
android:layout_marginTop="30dp"
android:textSize="18dp"
android:textAllCaps="false"
android:text="Submit"
android:textColor="#color/space_white"
android:background="#drawable/custombutton"
android:layout_width="match_parent"
android:layout_height="35dp" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/lytTab"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.tabs.TabLayout
app:tabBackground="#drawable/tab_indicator_color"
app:tabIndicatorColor="#color/button_red_back"
android:id="#+id/tabsLOc"
android:layout_marginTop="10dp"
app:tabTextAppearance="#style/MyCustomTextAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabGravity="fill"
app:tabMode="fixed" />
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewPagerLoc"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
and here is my fragment
public class EventFragment extends Fragment {
private View view;
ViewPagerAdapter viewPagerAdapter;
LocationPagerAdapter locationPagerAdapter;
private String current = "";
private String ddmmyyyy = "MMDDYYYY";
private Calendar cal = Calendar.getInstance();
FragmentEventBinding binding;
private OnFragmentInteractionListener mListener;
public EventFragment() {
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
binding = DataBindingUtil.inflate(
inflater, R.layout.fragment_event, container, false);
Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/Bebas Neue Pro Regular.otf");
binding.lytTopImg.setOnClickListener(v -> {
binding.lytLocDetails.setVisibility(View.VISIBLE);
binding.lytPartLocNew.setVisibility(View.GONE);
});
binding.imgTopEvent.setImageBitmap(SetBrightness(BitmapFactory.decodeResource(getResources(), R.drawable.dummy),-70));
binding.imgBackLocDetail.setOnClickListener(v -> {
binding.lytLocDetails.setVisibility(View.GONE);
binding.lytPartLocNew.setVisibility(View.VISIBLE);
/* Intent intent = new Intent(PartnerLocationActivity.this, LoactionDetails.class);
startActivity(intent);*/
});
binding.btnPlus.setOnClickListener(v -> {
binding.lyttabs.setVisibility(View.GONE);
binding.lytCreateEvent.setVisibility(View.VISIBLE);
});
binding.imgBack.setOnClickListener(v -> {
mListener.changeFragment(2);
binding.lyttabs.setVisibility(View.VISIBLE);
binding.lytCreateEvent.setVisibility(View.GONE);
});
binding.buttonCreateEvent.setOnClickListener(v -> {
binding.lyttabs.setVisibility(View.VISIBLE);
binding.lytCreateEvent.setVisibility(View.GONE);
});
binding.imgBackPartnerLoc.setOnClickListener(v -> {
binding.lytPartLocNew.setVisibility(View.GONE);
binding.lytCreateEvent.setVisibility(View.VISIBLE);
/* Intent intent = new Intent(getActivity(), CreateEvent.class);
startActivity(intent);*/
});
binding.lytTopPartLoc.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
binding.lytLocDetails.setVisibility(View.VISIBLE);
binding.lytPartLocNew.setVisibility(View.GONE);
}
});
binding.buttonCreateEvent.setTypeface(font);
binding.edtEventTitle.setTypeface(font);
binding.edtDescription.setTypeface(font);
binding.edtNameLoc.setTypeface(font);
binding.edtAddressLoc.setTypeface(font);
binding.rdbOne.setTypeface(font);
binding.rdbGroup.setTypeface(font);
binding.buttonPartnerloc.setOnClickListener(v -> {
binding.lytPartLocNew.setVisibility(View.VISIBLE);
binding.lytCreateEvent.setVisibility(View.GONE);
/* Intent intent = new Intent(CreateEvent.this, PartnerLocationActivity.class);
startActivity(intent);*/
});
binding.buttonCreateEvent.setOnClickListener(v -> {
binding.lyttabs.setVisibility(View.VISIBLE);
binding.lytCreateEvent.setVisibility(View.GONE);
});
binding.edtDob.addTextChangedListener(new TextWatcher() {
#Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
}
#Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
if (!s.toString().equals(current)) {
String clean = s.toString().replaceAll("[^\\d.]|\\.", "");
String cleanC = current.replaceAll("[^\\d.]|\\.", "");
int cl = clean.length();
int sel = cl;
for (int i = 2; i <= cl && i < 6; i += 2) {
sel++;
}
if (clean.equals(cleanC)) sel--;
if (clean.length() < 8) {
clean = clean + ddmmyyyy.substring(clean.length());
} else {
int day = Integer.parseInt(clean.substring(0, 2));
int mon = Integer.parseInt(clean.substring(2, 4));
int year = Integer.parseInt(clean.substring(4, 8));
mon = mon < 1 ? 1 : mon > 12 ? 12 : mon;
cal.set(Calendar.MONTH, mon - 1);
year = (year < 1900) ? 1900 : (year > 2100) ? 2100 : year;
cal.set(Calendar.YEAR, year);
day = (day > cal.getActualMaximum(Calendar.DATE)) ? cal.getActualMaximum(Calendar.DATE) : day;
clean = String.format("%02d%02d%02d", day, mon, year);
}
clean = String.format("%s/%s/%s", clean.substring(0, 2),
clean.substring(2, 4),
clean.substring(4, 8));
sel = sel < 0 ? 0 : sel;
current = clean;
binding.edtDob.setText(current);
binding.edtDob.setSelection(sel < current.length() ? sel : current.length());
}
}
#Override
public void afterTextChanged(Editable s) {
}
});
new Thread(new Runnable() {
#Override
public void run() {
try {
}catch (Exception ignored){
}
}
}).start();
viewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager());
binding.viewPager.setAdapter(viewPagerAdapter);
binding.tabs.setupWithViewPager( binding.viewPager);
/*binding.imgBack.setOnClickListener(v -> {
binding.lytLocDetails.setVisibility(View.GONE);
binding.lytPartLocNew.setVisibility(View.VISIBLE);
});*/
locationPagerAdapter = new LocationPagerAdapter(getFragmentManager());
binding.viewPagerLoc.setAdapter(locationPagerAdapter);
binding.tabsLOc.setupWithViewPager(binding.viewPagerLoc);
binding.edtSplReq.setTypeface(font);
binding.edtEmail.setTypeface(font);
binding.edtPhone.setTypeface(font);
binding.edtLastName.setTypeface(font);
binding.edtFirstname.setTypeface(font);
binding.btnSubmit.setTypeface(font);
binding.btnFindTable.setTypeface(font);
binding.btnFindTable.setOnClickListener(v -> {
binding.lytBtnFind.setVisibility(View.GONE);
binding.lytTab.setVisibility(View.GONE);
binding.lytBookTable.setVisibility(View.VISIBLE);
});
binding.btnSubmit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
binding.lyttabs.setVisibility(View.VISIBLE);
binding.lytLocDetails.setVisibility(View.GONE);
binding.lytPartLocNew.setVisibility(View.GONE);
binding.lytCreateEvent.setVisibility(View.GONE);
binding.lytBookTable.setVisibility(View.GONE);
binding.lytBtnFind.setVisibility(View.VISIBLE);
binding.lytTab.setVisibility(View.VISIBLE);
binding.viewPager.setCurrentItem(1);
binding.tabs.getSelectedTabPosition();
}
});
return view = binding.getRoot();
}
#Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
mListener = (OnFragmentInteractionListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString()
+ " must implement OnFragmentInteractionListener");
}
}
#Override
public void onDetach() {
super.onDetach();
mListener = null;
}
public Bitmap SetBrightness(Bitmap src, int value) {
// original image size
int width = src.getWidth();
int height = src.getHeight();
// create output bitmap
Bitmap bmOut = Bitmap.createBitmap(width, height, src.getConfig());
// color information
int A, R, G, B;
int pixel;
// scan through all pixels
for(int x = 0; x < width; ++x) {
for(int y = 0; y < height; ++y) {
// get pixel color
pixel = src.getPixel(x, y);
A = Color.alpha(pixel);
R = Color.red(pixel);
G = Color.green(pixel);
B = Color.blue(pixel);
// increase/decrease each channel
R += value;
if(R > 255) { R = 255; }
else if(R < 0) { R = 0; }
G += value;
if(G > 255) { G = 255; }
else if(G < 0) { G = 0; }
B += value;
if(B > 255) { B = 255; }
else if(B < 0) { B = 0; }
bmOut.setPixel(x, y, Color.argb(A, R, G, B));
}
}
// return final image
return bmOut;
}
}
There are two parts to this answer.
As per https://developer.android.com/topic/performance/rendering/optimizing-view-hierarchies
Android Layouts allow you to nest UI objects in the view hierarchy. This nesting can also impose a layout cost.
Your layout has multiple levels of nesting, this can have a large cost to layout.
Simplifying you layout with a more flexible layout like a ConstraintLayout Might reduce the layout cost.
Sometimes you are just trying to do too much when creating a view, do some of the work in a background thread and update the view when done (optionally putting up a busy type of progress bar while doing it)
Some idea's based on your code shown.
Instead of scanning every pixel of an image with the SetBrightness method which could take some time depending on the size of the image.
Add the image to the layout without the Brightness adjusted, start background task adjust image Brightness and when done replace the original un-adjusted image with the adjusted image.
This could probably be done without a busy progress bar.
Delay the creation of the offscreen viewpager pages until they are really needed.
Instead of each Fragment in the viewpager creating it's view in onCreateView when the Viewpager is created, create a placeholder view in the Fragment's onCreateView and update it in the Fragment's onResume which is only called when the Fragment is shown on screen (note need a recent'ish version of Viewpager for this behaviour)
I'm trying to add a parallel effect in between bottom sheet layout and map view.but google log in map view is hidden when expending the bottom sheet layout. [Google logo is hidden]
show google logo when bottom sheet collapse
I'm using below code:
layout
<android.support.design.widget.CoordinatorLayout
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/Green"
tools:context=".ui.activities.ChooseLocationActivity">
<RelativeLayout
android:id="#+id/map_rlyt"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.koya.android.ui.widget.CollapseBehavior"
app:layout_anchor="#+id/bottom_sheet_layout">
<fragment
android:id="#+id/g_map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/category_activity_container"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/category_search_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/custom_edit_text_margin_top"
android:layout_marginLeft="#dimen/custom_edit_text_margin_left_right"
android:layout_marginRight="#dimen/custom_edit_text_margin_left_right"
android:background="#android:color/transparent">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/ic_back_iv"
android:padding="#dimen/location_activity_back_button_padding"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#mipmap/ic_back_black"/>
<EditText
android:id="#+id/editTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="#dimen/custom_edit_text_padding"
android:textColor="#color/black"
android:drawablePadding="8dp"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:drawableLeft="#mipmap/ic_search_gray"
android:textCursorDrawable="#drawable/edit_text_cursor_drawable"
android:drawableRight="#mipmap/ic_close_gray"
android:textSize="#dimen/custom_edit_text_text_size"
android:background="#drawable/drawable_custom_edittext"
/>
</LinearLayout>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_centerInParent="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone"/>
<Button
android:id="#+id/redo_search_in_map_area_button"
style="#style/CategoryChooseButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/category_search_box"
android:layout_centerInParent="true"
android:layout_marginTop="#dimen/fifteen_text_size"
android:animateLayoutChanges="true"
android:paddingEnd="#dimen/redo_search_button_padding"
android:paddingStart="#dimen/redo_search_button_padding"
android:text="#string/redo_search_in_map_area"
android:textAllCaps="false"
android:visibility="gone"
/>
</RelativeLayout>
<include
android:id="#+id/bottom_sheet_layout"
layout="#layout/bottom_sheet"/>
<Button
android:id="#+id/select_location_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="#string/use_selected_location"
android:visibility="gone"
tools:visibility="visible"
style="#style/CategoryChooseButtonStyle"/>
<include android:id="#+id/error_layout"
layout="#layout/error_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
/>
And Implement Coordinatorlayout.Behavior
public class CollapseBehavior<V extends ViewGroup> extends CoordinatorLayout.Behavior<V>{
public CollapseBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
#Override
public boolean onDependentViewChanged(CoordinatorLayout parent, V child, View dependency) {
if (isBottomSheet(dependency)) {
BottomSheetBehavior behavior = ((BottomSheetBehavior) ((CoordinatorLayout.LayoutParams) dependency.getLayoutParams()).getBehavior());
int peekHeight = behavior.getPeekHeight();
// The default peek height is -1, which
// gets resolved to a 16:9 ratio with the parent
final int actualPeek = peekHeight >= 0 ? peekHeight : (int) (((parent.getHeight() * 1.0) / (16.0)) * 9.0);
if (dependency.getTop() >= actualPeek) {
// Only perform translations when the
// view is between "hidden" and "collapsed" states
final int dy = dependency.getTop() - parent.getHeight();
ViewCompat.setTranslationY(child, dy/2);
return true;
}
}
return false;
}
private static boolean isBottomSheet(#NonNull
View view) {
final ViewGroup.LayoutParams lp = view.getLayoutParams();
if (lp instanceof CoordinatorLayout.LayoutParams) {
return ((CoordinatorLayout.LayoutParams) lp)
.getBehavior() instanceof BottomSheetBehavior;
}
return false;
}
}
I need this type of scrolling in my application -->
https://streamable.com/g0tf9
How to scroll google map when bottom sheet expend with parallax effect? I would appreciate it a lot!
Thanks in Advance.
There are only two items in my listview and it covers half of screen but listview still shows scroll around it. I have set height to wrap_content
layout code is below:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/listLikeWhatsapp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:divider="#android:color/transparent"
android:dividerHeight="10.0sp"
/>
</LinearLayout>
I don't want scroll to appear on listview because it will have only two items and there is no need to show. I am not sure what is causing scroll to appear.
Any help would be highly appreciated.
Thanking you in advance
UPDATE
Here is my row item xml :
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#drawable/roundedshape"
android:alpha="0.7">
<ImageView
android:id="#+id/icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:contentDescription="desc"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:src="#drawable/ic_insert_emoticon_black_48dp"
/>
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/icon"
android:paddingBottom="5dp"
android:text="Assignments"
android:textStyle="bold"
android:textSize="18sp"
android:textColor="#000"/>
<TextView
android:id="#+id/last_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/title"
android:layout_below="#+id/title"
android:text="Last Update : 01-01-2017"
android:textSize="13sp"
android:textColor="#696969"/>
<TextView
android:id="#+id/unread_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/title"
android:layout_alignBottom="#+id/title"
android:layout_alignParentRight="true"
android:text="04"
android:textSize="12sp"
android:background="#drawable/shape_circular"
android:padding="5dp"
android:textColor="#FFF"
android:textStyle="bold"
android:layout_marginRight="5dp"
/>
</RelativeLayout>
<ListView
...
android:scrollbars="none"
...
/>
try adding:
android:scrollbars="none"
user android:scrollbar="none" like this;
<ListView
android:id="#+id/list_view_meals_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
To hide scrollbars
do this
android:scrollbars="none"
To disable scrolling do this
listView.setOnTouchListener(new View.OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
return (event.getAction() == MotionEvent.ACTION_MOVE);
}
});
PS: I think you have messed up your item view which includes icon title and description.
Use this 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" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="your text view"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:id="#+id/text_ap"/>
<ListView
android:id="#+id/listLikeWhatsapp"
android:layout_width="match_parent"
android:layout_above="#id/text_ap"
android:layout_height="match_parent"/>
</RelativeLayout>
try this :
to hide the scrollbar
<ListView
android:id="#+id/listLikeWhatsapp"
android:layout_width="match_parent"
android:scrollbars="none" // add this
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:divider="#android:color/transparent"
android:dividerHeight="10.0sp"
/>
or in your code:
yourlistView.setVerticalScrollBarEnabled(false);
To disable Scrolling of listview Items try:
listView.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_MOVE) {
return true; // Action will not be forwarded
}
return false;
}
});
OR
yourListView.setScrollContainer(false);
I know it's an old question i was searching for solution and i remembered that i use it in another project and i forgot the owner of the solution so here is the code :
public static void justifyListViewHeightBasedOnChildren (ListView listView) {
ListAdapter adapter = listView.getAdapter();
if (adapter == null) {
return;
}
ViewGroup vg = listView;
int totalHeight = 0;
for (int i = 0; i < adapter.getCount(); i++) {
View listItem = adapter.getView(i, null, vg);
listItem.measure(0, 0);
totalHeight += listItem.getMeasuredHeight();
}
ViewGroup.LayoutParams par = listView.getLayoutParams();
par.height = totalHeight + (listView.getDividerHeight() * (adapter.getCount() - 1));
listView.setLayoutParams(par);
listView.requestLayout();
}
I am trying to change height of android appBarLayout to make effect like this (example is from iOS but I am trying to do similar things in android):
When we scroll up appBar height of appBar should decrese and picture should scaled.
Example 1: http://take.ms/nxVJ7
Example 2: http://take.ms/jXQst
After some research and several attemptes I have some progress, but I have no idea what to do next.
This is my activity_profile:
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="350dp"
android:theme="#style/AppTheme.AppBarOverlay"
android:minHeight="250dp"
app:elevation="0dp"
app:layout_behavior=".utils.behaviors.DisappearBehavior"
>
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary">
<TextView
android:id="#+id/title"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"/>
</android.support.v7.widget.Toolbar>
<LinearLayout
android:id="#+id/app_bar_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp">
<TextView
android:id="#+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="online"/>
<ImageButton
android:id="#+id/edit_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:background="#drawable/button_circle"
android:src="#drawable/ic_edit"
android:tint="#color/colorPrimary"
android:visibility="gone"/>
<ImageView
android:id="#+id/vip_status_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/status"
android:src="#drawable/ic_vip"
android:tint="#color/colorPrimary"/>
</RelativeLayout>
<ImageView
android:id="#+id/avatar"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center_horizontal"
android:src="#drawable/ic_avatar_placeholder"
android:adjustViewBounds="true"
android:layout_weight="1"/>
<TextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="30dp"
android:gravity="center"
android:text="Демин Сергей"
android:textColor="#color/colorBlack"
android:textSize="18sp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="#drawable/ic_avatar_placeholder"
/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="#drawable/ic_avatar_placeholder"
/>
<ImageView
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:src="#drawable/ic_avatar_placeholder"
/>
</LinearLayout>
</LinearLayout>
</android.support.design.widget.AppBarLayout>
<FrameLayout
android:id="#+id/frame_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorWhite"
app:layout_behavior="#string/appbar_scrolling_view_behavio">
<ProgressBar
android:id="#+id/progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible"/>
<android.support.v4.widget.NestedScrollView
android:id="#+id/content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="visible">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
And DisappearBehavior:
public class DisappearBehavior extends CoordinatorLayout.Behavior<AppBarLayout> {
public DisappearBehavior(Context context, AttributeSet attrs) {
super(context, attrs);
}
#Override
public boolean onStartNestedScroll(
CoordinatorLayout coordinatorLayout, AppBarLayout child, View directTargetChild, View target, int nestedScrollAxes) {
if (nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL) {
return true;
} else {
return false;
}
}
#Override
public void onNestedPreScroll(
CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dx, int dy, int[] consumed) {
consumed = new int[2];
consumed[1] = dy;
ViewGroup.LayoutParams params = child.getLayoutParams();
Log.d("Behavior", "dy = " + dy);
params.height -= dy;
child.setLayoutParams(params);
}
#Override
public void onNestedScroll(
CoordinatorLayout coordinatorLayout, AppBarLayout child, View target, int dxConsumed, int dyConsumed,
int dxUnconsumed,
int dyUnconsumed) {
ViewGroup.LayoutParams params = child.getLayoutParams();
child.setLayoutParams(params);
int xxx = child.getBottom();
Log.d("Behavior", "height = " + params.height + " " + xxx);
}
#Override
public void onStopNestedScroll(CoordinatorLayout coordinatorLayout, AppBarLayout child, View target) {
super.onStopNestedScroll(coordinatorLayout, child, target);
ViewGroup.LayoutParams params = child.getLayoutParams();
child.setLayoutParams(params);
int xxx = child.getBottom();
Log.d("Behavior", "stop height = " + params.height + " " + xxx);
}
}
In the result I have effect when both appBarLayout and FrameLayout with content scrolling simultaneously (I'll try to add images if I'll found a way how to do it. I need more than 10 reputation. image3, image4).
Also there is some starnge effect. When you scroll up (for example) slowly you could see text on screen moving up and the again down. Smth like quake effect.
As you see I have logs in the code and they says me that dy is positive and negative when I scroll in one direction.
Log for slow up scroll for example:
dy = 42
height = 924 1026
dy = -36
height = 960 984
dy = 43
height = 917 1020
dy = -37
height = 954 977
dy = 42
height = 912 1014
dy = -36
height = 948 972
dy = 48
height = 808 916
dy = -44
height = 852 868
dy = 46
height = 806 912
dy = -46
height = 852 866
stop height = 852 866
I understand that all problems come AppBarLayout$ScrollingViewBehavior but I do not understand what to change.
/*This is my mainActivity.class*/
public class MainActivity extends ActionBarActivity{
attachFragments();
}
private void attachFragments() {
CustomFragment chatFragment=new CustomFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
transaction.add(R.id.first, chatFragment);
transaction.commit();
}
}
/*mainActivity.xml*/
<?xml version="1.0" encoding="utf-8"?>
< com.prospus.poms.layout.CustomSlidingLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mainLayout"
android:layout_height="match_parent"
android:layout_width="match_parent">
<RelativeLayout
android:id="#+id/first"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/second"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</RelativeLayout>
<RelativeLayout
android:id="#+id/third"
android:layout_width="wrap_content"
android:layout_height="match_parent" >
</RelativeLayout>
</com.prospus.poms.layout.CustomSlidingLayout>
CustomSlidingLayout.java
public class CustomSlidingLayout extends LinearLayout {
private static final int SLIDING_DURATION = 500;
private static final int QUERY_INTERVAL = 16;
int mainLayoutWidth;
private View menuRight;
private View content;
private enum MenuState {
HIDING, HIDDEN, SHOWING, SHOWN,
};
private int contentXOffset;
private int menuWidth;
private int rightMenuOffset;
private MenuState currentMenuState = MenuState.HIDDEN;
private Scroller menuScroller = new Scroller(this.getContext(),
new EaseInInterpolator());
private Runnable rightMenuRunnable = new MenuRightRunnable();
private Handler menuHandler = new Handler();
public CustomSlidingLayout(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomSlidingLayout(Context context) {
super(context);
}
#Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
mainLayoutWidth = MeasureSpec.getSize(widthMeasureSpec);
menuWidth=mainLayoutWidth;
}
#Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
content = this.getChildAt(0);
menuRight = getChildAt(1);
menuRight.setVisibility(View.GONE);
}
#Override
protected void onLayout(boolean changed, int left, int top, int right,
int bottom) {
if (changed) {
LayoutParams contentLayoutParams = (LayoutParams) content
.getLayoutParams();
contentLayoutParams.height = this.getHeight();
contentLayoutParams.width = this.getWidth();
LayoutParams menuLayoutParams = (LayoutParams) menuRight.getLayoutParams();
menuLayoutParams.height = this.getHeight();
menuLayoutParams.width = this.getWidth();
}
menuRight.layout(right - rightMenuOffset, top, right - rightMenuOffset
+ menuWidth, bottom);
content.layout(left, top, right, bottom);
}
#SuppressLint("NewApi")
public void toggleRightMenu() {
if (currentMenuState == MenuState.HIDING
|| currentMenuState == MenuState.SHOWING)
return;
switch (currentMenuState) {
case HIDDEN:
currentMenuState = MenuState.SHOWING;
menuRight.setVisibility(View.VISIBLE);
menuScroller.startScroll(0, 0,
-menuRight.getLayoutParams().width, 0, SLIDING_DURATION);
contentXOffset = 0;
rightMenuOffset = 0;
invalidate();
break;
case SHOWN:
currentMenuState = MenuState.HIDING;
menuScroller.startScroll(contentXOffset, 0, -contentXOffset, 0,
SLIDING_DURATION);
break;
default:
break;
}
menuHandler.postDelayed(rightMenuRunnable, QUERY_INTERVAL);
this.invalidate();
}
protected class MenuRightRunnable implements Runnable {
#Override
public void run() {
boolean isScrolling = menuScroller.computeScrollOffset();
adjustRightContentPosition(isScrolling);
}
}
#SuppressLint("NewApi")
private void adjustRightContentPosition(boolean isScrolling) {
int scrollerXOffset = menuScroller.getCurrX();
menuRight.offsetLeftAndRight(scrollerXOffset - contentXOffset);
rightMenuOffset += (contentXOffset-scrollerXOffset );
contentXOffset = scrollerXOffset;
this.invalidate();
if (isScrolling)
menuHandler.postDelayed(rightMenuRunnable, QUERY_INTERVAL);
else
this.onMenuSlidingComplete();
}
private void onMenuSlidingComplete() {
switch (currentMenuState) {
case SHOWING:
currentMenuState = MenuState.SHOWN;
break;
case HIDING:
currentMenuState = MenuState.HIDDEN;
break;
default:
return;
}
}
protected class EaseInInterpolator implements Interpolator {
#Override
public float getInterpolation(float t) {
return (float) Math.pow(t - 1, 5) + 1;
}
}
public boolean isMenuShown() {
return currentMenuState == MenuState.SHOWN;
}
}
/*I am using this customlayout in main activity and in each sub layout attching a fragment. */
/* Layout file of fragment: */
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="#layout/header_layout" />
</LinearLayout>
<LinearLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomLayout"
android:layout_below="#id/title_layout"
android:orientation="horizontal" >
<ListView
android:id="#+id/chatList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#android:color/transparent"
android:divider="#android:color/black"
android:fadeScrollbars="false"
android:fadingEdge="none"
android:isScrollContainer="false"
android:listSelector="#android:color/transparent"
android:overScrollMode="never"
android:scrollbarStyle="insideInset"
android:scrollbars="vertical"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/title_background"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/upload"
android:layout_width="#dimen/BASE_50_DP"
android:layout_height="match_parent"
android:layout_gravity="bottom" >
<ImageView
android:id="#+id/upload_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
<EditText
android:id="#+id/chattext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="#dimen/BASE_5_DP"
android:layout_marginTop="#dimen/BASE_5_DP"
android:layout_weight="1"
android:background="#android:color/white"
android:maxHeight="#dimen/EditTextHeight"
android:minHeight="#dimen/BASE_45_DP"
android:padding="#dimen/BASE_5_DP"
android:selectAllOnFocus="true"
android:singleLine="false" />
<RelativeLayout
android:layout_width="#dimen/BASE_50_DP"
android:layout_height="match_parent"
android:layout_gravity="bottom" >
<ImageView
android:id="#+id/done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/ic_launcher" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
kayboard hide the editText but when keyboard hides, editText comes in middle of screen. Exactly opposite the requirement. I know main problem is my custom layout. Please tell me what is wrong in this customlayout. Everything works fine if i replace the customLayout with relativeLayoot. but i have to use this layout. Please help me.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="#layout/header_layout" />
</LinearLayout>
<LinearLayout
android:id="#+id/main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomLayout"
android:layout_below="#id/title_layout"
android:orientation="horizontal" >
<ListView
android:id="#+id/chatList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:cacheColorHint="#android:color/transparent"
android:divider="#android:color/black"
android:fadeScrollbars="false"
android:fadingEdge="none"
android:listSelector="#android:color/transparent"
android:overScrollMode="never"
android:scrollbarStyle="insideInset"
android:scrollbarThumbVertical="#drawable/scrollbar_thumb"
android:scrollbarTrackVertical="#drawable/scrollbar_vertical_track"
android:scrollbars="vertical"
android:stackFromBottom="true"
android:transcriptMode="alwaysScroll" >
</ListView>
</LinearLayout>
<LinearLayout
android:id="#id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/title_background"
android:orientation="horizontal" >
<RelativeLayout
android:id="#+id/upload"
android:layout_width="#dimen/BASE_50_DP"
android:layout_height="match_parent"
android:layout_gravity="bottom" >
<ImageView
android:id="#+id/upload_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/upload_icon" />
</RelativeLayout>
<EditText
android:id="#+id/chattext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="#dimen/BASE_5_DP"
android:layout_marginTop="#dimen/BASE_5_DP"
android:layout_weight="1"
android:background="#android:color/white"
android:maxHeight="#dimen/EditTextHeight"
android:minHeight="#dimen/BASE_45_DP"
android:padding="#dimen/BASE_5_DP"
android:selectAllOnFocus="true"
android:singleLine="false" />
<RelativeLayout
android:layout_width="#dimen/BASE_50_DP"
android:layout_height="match_parent"
android:layout_gravity="bottom" >
<ImageView
android:id="#+id/done"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/input_done_icon" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</ScrollView>
put all view is scrollview
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/title_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<include layout="#layout/header_layout" />
</LinearLayout>
.....
</RelativeLayout>
</ScrollView>
Just wrap the whole Relative layout inside a ScrollView.
also
NOTE that scrollview can only have 1 child view
and that will be your outermost reletive layout.
ans the above link to documentation for scrollview methods that can be used to set different properties in java file.