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)
Related
I have a view in my android project like :
I want to show a header when I scroll down when the Title (lblHeaderJobTitle in the code below) reaches the top, and hide it back when the title is visible in the screen when I scroll up.
<androidx.coordinatorlayout.widget.CoordinatorLayout
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"
android:fitsSystemWindows="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayoutHeader"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
android:paddingStart="#dimen/margin4"
android:paddingEnd="#dimen/margin4"
android:layout_gravity="top"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<TextView
android:id="#+id/lblHeaderJobTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="#font/poppins_semibold"
android:textSize="#dimen/t4"
android:includeFontPadding="false"
android:textColor="#color/darkGrey"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:MvxBind="Text Title"/>
<TextView
android:id="#+id/lblHeaderJobCompanyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="#dimen/margin2"
android:fontFamily="#font/mulish_bold"
android:textSize="#dimen/t2"
android:textColor="#color/darkGrey"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#id/lblHeaderJobTitle"
app:layout_constraintEnd_toStartOf="#id/verticalSeparatorHeader"
app:MvxBind="Text CompanyName"/>
<TextView
android:id="#+id/verticalSeparatorHeader"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="|"
android:fontFamily="#font/mulish_regular"
android:textSize="#dimen/t2"
android:textColor="#color/darkGrey"
app:layout_constraintTop_toTopOf="#id/lblHeaderJobCompanyName"
app:layout_constraintStart_toEndOf="#id/lblHeaderJobCompanyName"
app:layout_constraintEnd_toStartOf="#id/lblHeaderJobLocation"/>
<TextView
android:id="#+id/lblHeaderJobLocation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="#font/mulish_regular"
android:textSize="#dimen/t2"
android:textColor="#color/darkGrey"
android:layout_marginLeft="#dimen/margin2"
app:layout_constraintTop_toTopOf="#id/lblHeaderJobCompanyName"
app:layout_constraintStart_toEndOf="#id/verticalSeparatorHeader"
app:MvxBind="Text LblLocation"/>
<View
android:id="#+id/imgHeaderSeparator"
android:layout_width="0dp"
android:layout_height="1dp"
android:background="#color/silver"
android:layout_marginTop="11dp"
app:layout_constraintTop_toBottomOf="#id/lblHeaderJobLocation"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.core.widget.NestedScrollView
android:id="#+id/nestedScrollViewJobDetail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fillViewport="true">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="#dimen/margin4"
android:paddingEnd="#dimen/margin4">
<ImageView
android:id="#+id/imgBrandingLogo"
android:layout_width="match_parent"
android:layout_height="100dp"
android:scaleType="centerInside"
android:background="#drawable/bg_roundrect_ripple_light_border"
app:MvxBind="DrawableName DefaultCompanyPhotoDrawable"/>
<TextView
android:id="#+id/lblJobTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin3"
android:layout_marginBottom="#dimen/margin2"
android:fontFamily="#font/poppins_semibold"
android:textSize="#dimen/t8"
android:includeFontPadding="false"
android:textColor="#color/darkGrey"
app:layout_constraintTop_toBottomOf="#id/relativeLayoutJobDetail"
app:MvxBind="Text Title"/>
<ImageView
android:id="#+id/imgJobLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin1"
android:src="#drawable/ic_location_on_black_24dp"
app:layout_constraintTop_toBottomOf="#id/lblJobTitle"/>
<TextView
android:id="#+id/lblJobCompanyName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin2"
android:layout_marginRight="#dimen/margin2"
android:fontFamily="#font/mulish_bold"
android:textSize="#dimen/t4"
android:textColor="#color/darkGrey"
app:layout_constraintStart_toEndOf="#id/imgJobLocation"
app:layout_constraintTop_toTopOf="#id/imgJobLocation"
app:layout_constraintEnd_toStartOf="#id/verticalSeparator"
app:MvxBind="Text CompanyName"/>
<TextView
android:id="#+id/verticalSeparator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="|"
android:fontFamily="#font/mulish_regular"
android:textSize="#dimen/t4"
android:textColor="#color/darkGrey"
app:layout_constraintTop_toTopOf="#id/lblJobCompanyName"
app:layout_constraintStart_toEndOf="#id/lblJobCompanyName"
app:layout_constraintEnd_toStartOf="#id/lblJobLocation"/>
<TextView
android:id="#+id/lblJobLocation"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:fontFamily="#font/mulish_regular"
android:textSize="#dimen/t4"
android:textColor="#color/darkGrey"
android:layout_marginLeft="#dimen/margin2"
app:layout_constraintTop_toTopOf="#id/lblJobCompanyName"
app:layout_constraintStart_toEndOf="#id/verticalSeparator"
app:MvxBind="Text LblLocation"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.core.widget.NestedScrollView>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/constraintLayoutBtnGroup"
android:layout_width="match_parent"
android:layout_height="63dp"
android:visibility="invisible"
android:paddingStart="#dimen/margin4"
android:paddingEnd="#dimen/margin4"
android:paddingBottom="#dimen/margin2"
android:layout_gravity="center_horizontal|bottom">
<Button
style="#style/Button.Tertiary"
android:id="#+id/btnSaveNow"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:layout_marginLeft="#dimen/margin2"
android:fontFamily="#font/poppins_semibold"
app:icon="#drawable/ic_star_black_24dp"
app:layout_constraintTop_toTopOf="#id/frameLayoutApplyFix"
app:layout_constraintStart_toEndOf="#id/frameLayoutApplyFix"
app:layout_constraintBottom_toBottomOf="#id/frameLayoutApplyFix"
app:layout_constraintEnd_toEndOf="parent"
app:MvxBind="Text BtnSave; Click SaveCommand"/>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
In my activity I tried this:
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
// Create your application here
_constraintLayoutHeader = FindViewById<ConstraintLayout>(Resource.Id.constraintLayoutHeader);
_constraintLayoutBtnGroup = FindViewById<ConstraintLayout>(Resource.Id.constraintLayoutBtnGroup);
((CoordinatorLayout.LayoutParams)_constraintLayoutBtnGroup.LayoutParameters).Behavior = new StickyBottomBehavior(Resource.Id.frameLayoutApply, Resource.Id.nestedScrollViewJobDetail, EPosition.Bottom);
((CoordinatorLayout.LayoutParams)_constraintLayoutHeader.LayoutParameters).Behavior = new StickyBottomBehavior(Resource.Id.lblJobLocation, Resource.Id.nestedScrollViewJobDetail, EPosition.Top);
}
In my custom behavior:
public class StickyBottomBehavior : CoordinatorLayout.Behavior
{
#region Properties
private int _anchorId;
private int _scrollViewId;
private EPosition _position;
#endregion
#region Constructor
public StickyBottomBehavior(int anchorId, int scrollViewId, EPosition ePosition)
{
_anchorId = anchorId;
_scrollViewId = scrollViewId;
_position = ePosition;
}
#endregion
public override bool OnStartNestedScroll(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View directTargetChild, View target, int axes, int type)
{
return (axes == ((int)Vertical));
}
public override void OnNestedPreScroll(CoordinatorLayout coordinatorLayout, Java.Lang.Object child, View target, int dx, int dy, int[] consumed, int type)
{
var anchor = coordinatorLayout.FindViewById(_anchorId);
NestedScrollView scrollView = coordinatorLayout.FindViewById<NestedScrollView>(_scrollViewId);
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams)scrollView.LayoutParameters;
int[] anchorLocation = new int[2];
View childView = child.JavaCast<View>();
anchor.GetLocationInWindow(anchorLocation);
switch (_position)
{
case EPosition.Top:
if (anchorLocation[1] < 0)
{
childView.Visibility = ViewStates.Visible;
layoutParams.TopMargin = childView.Height;
scrollView.LayoutParameters = layoutParams;
}
else
{
childView.Visibility = ViewStates.Invisible;
layoutParams.TopMargin = 0;
scrollView.LayoutParameters = layoutParams;
}
break;
case EPosition.Bottom:
if (anchorLocation[1] < 0)
{
childView.Visibility = ViewStates.Visible;
layoutParams.BottomMargin = childView.Height + 8;
scrollView.LayoutParameters = layoutParams;
}
else
{
childView.Visibility = ViewStates.Invisible;
layoutParams.BottomMargin = 0;
scrollView.LayoutParameters = layoutParams;
}
break;
default:
break;
}
}
}
public enum EPosition
{
Top,
Bottom
}
For the sticky buttons in the bottom it works very well but for the header there is smt wrong when I reach the Title in the top the screen is moving weirdly.
Demo: https://www.veed.io/view/6e1c9b71-b10d-46c7-a284-18b974a0bb7e
Is there another way to do that ? or there is smt wrong in my code ?
Thanks for the help.
I have a horizontal recycleview which can scroll & snap center. Then I want a bottom line indicator to indicate selected item when click on it. It looks like this:
I had a look at this library but it doesn't fit my requirements.
Is there idea to implement this one?
Update: I need to keep the indicator is always visible and has a smooth scroll when moving to another position like above gift
You can try the following code:
DateTabIndicator.java
public class DateTabIndicator extends FrameLayout implements View.OnClickListener {
private List<Integer> days = new ArrayList<>();
private int selectedPageIndex = 0;
private int selectedDayIndex = 0;
private static final int[] DAY_TV_RES_ID = {R.id.day_mon, R.id.day_tue, R.id.day_wed, R.id.day_thu, R.id.day_fri, R.id.day_sat,
R.id.day_sun};
public DateTabIndicator(#NonNull Context context) {
super(context);
init();
}
public DateTabIndicator(#NonNull Context context, #Nullable AttributeSet attrs) {
super(context, attrs);
init();
}
public DateTabIndicator(#NonNull Context context, #Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private TextView monFixedIndicator;
private TextView tueFixedIndicator;
private TextView wedFixedIndicator;
private TextView thuFixedIndicator;
private TextView friFixedIndicator;
private TextView satFixedIndicator;
private TextView sunFixedIndicator;
private View lineIndicator;
private ViewPager daysPager;
private DaysPagerAdapter daysPagerAdapter;
private Handler mHandler = new Handler();
private void init() {
addView(LayoutInflater.from(getContext()).inflate(R.layout.date_tab_indicator, this, false));
monFixedIndicator = findViewById(R.id.mon_fixed_indicator);
tueFixedIndicator = findViewById(R.id.tue_fixed_indicator);
wedFixedIndicator = findViewById(R.id.wed_fixed_indicator);
thuFixedIndicator = findViewById(R.id.thu_fixed_indicator);
friFixedIndicator = findViewById(R.id.fri_fixed_indicator);
satFixedIndicator = findViewById(R.id.sat_fixed_indicator);
sunFixedIndicator = findViewById(R.id.sun_fixed_indicator);
lineIndicator = findViewById(R.id.line_indicator);
daysPager = findViewById(R.id.days_pager);
daysPagerAdapter = new DaysPagerAdapter();
daysPager.setAdapter(daysPagerAdapter);
daysPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
#Override
public void onPageSelected(int position) {
selectedPageIndex = position;
mHandler.removeCallbacks(selectDayRunnable);
mHandler.postDelayed(selectDayRunnable,500);
}
#Override
public void onPageScrollStateChanged(int state) {
}
});
mHandler.postDelayed(selectDayRunnable,500);
}
class DaysPagerAdapter extends PagerAdapter {
#Override
public int getCount() {
return (int) Math.ceil(days.size() / 7f);
}
#NonNull
#Override
public Object instantiateItem(#NonNull ViewGroup container, final int position) {
final View view = LayoutInflater.from(getContext()).inflate(R.layout.days_pager_item, container, false);
TextView dayMonTv = view.findViewById(R.id.day_mon);
TextView dayTueTv = view.findViewById(R.id.day_tue);
TextView dayWedTv = view.findViewById(R.id.day_wed);
TextView dayThuTv = view.findViewById(R.id.day_thu);
TextView dayFriTv = view.findViewById(R.id.day_fri);
TextView daySatTv = view.findViewById(R.id.day_sat);
TextView daySunTv = view.findViewById(R.id.day_sun);
//Setting Day Text
int index = position * 7;
dayMonTv.setText(days.size() > index ? String.valueOf(days.get(index)) : "");
dayTueTv.setText(days.size() > (++index) ? String.valueOf(days.get(index)) : "");
dayWedTv.setText(days.size() > (++index) ? String.valueOf(days.get(index)) : "");
dayThuTv.setText(days.size() > (++index) ? String.valueOf(days.get(index)) : "");
dayFriTv.setText(days.size() > (++index) ? String.valueOf(days.get(index)) : "");
daySatTv.setText(days.size() > (++index) ? String.valueOf(days.get(index)) : "");
daySunTv.setText(days.size() > (++index) ? String.valueOf(days.get(index)) : "");
//Setting Day VISIBILITY
index = position * 7;
dayMonTv.setVisibility(days.size() > index && days.get(index) != 0 ? VISIBLE : INVISIBLE);
dayTueTv.setVisibility(days.size() > ++index && days.get(index) != 0 ? VISIBLE : INVISIBLE);
dayWedTv.setVisibility(days.size() > ++index && days.get(index) != 0 ? VISIBLE : INVISIBLE);
dayThuTv.setVisibility(days.size() > ++index && days.get(index) != 0 ? VISIBLE : INVISIBLE);
dayFriTv.setVisibility(days.size() > ++index && days.get(index) != 0 ? VISIBLE : INVISIBLE);
daySatTv.setVisibility(days.size() > ++index && days.get(index) != 0 ? VISIBLE : INVISIBLE);
daySunTv.setVisibility(days.size() > ++index && days.get(index) != 0 ? VISIBLE : INVISIBLE);
//Setting Selection
dayMonTv.setSelected(false);
dayTueTv.setSelected(false);
dayWedTv.setSelected(false);
dayThuTv.setSelected(false);
dayFriTv.setSelected(false);
daySatTv.setSelected(false);
daySunTv.setSelected(false);
//Setting Click Listener
dayMonTv.setOnClickListener(DateTabIndicator.this);
dayTueTv.setOnClickListener(DateTabIndicator.this);
dayWedTv.setOnClickListener(DateTabIndicator.this);
dayThuTv.setOnClickListener(DateTabIndicator.this);
dayFriTv.setOnClickListener(DateTabIndicator.this);
daySatTv.setOnClickListener(DateTabIndicator.this);
daySunTv.setOnClickListener(DateTabIndicator.this);
view.setTag(position);
container.addView(view);
return view;
}
#Override
public void destroyItem(#NonNull ViewGroup container, int position, #NonNull Object object) {
container.removeView((View) object);
}
#Override
public boolean isViewFromObject(#NonNull View view, #NonNull Object object) {
return view == object;
}
}
public List<Integer> getDays() {
return days;
}
public void setDays(List<Integer> days) {
this.days = days;
daysPagerAdapter.notifyDataSetChanged();
}
private View prevDayTv = null;
#Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.day_mon:
selectDay(v, 0);
break;
case R.id.day_tue:
selectDay(v, 1);
break;
case R.id.day_wed:
selectDay(v, 2);
break;
case R.id.day_thu:
selectDay(v, 3);
break;
case R.id.day_fri:
selectDay(v, 4);
break;
case R.id.day_sat:
selectDay(v, 5);
break;
case R.id.day_sun:
selectDay(v, 6);
break;
}
}
/**
* #param dayIndex 0-6
*/
private void selectDay(View v, int dayIndex) {
selectedDayIndex = dayIndex;
int dayListIndex = selectedPageIndex * 7 + dayIndex;
if (prevDayTv != null) prevDayTv.setSelected(false);
v.setSelected(true);
prevDayTv = v;
int[] location = new int[2];
v.getLocationOnScreen(location);
int center_point = location[0]%getWidth() + v.getWidth() / 2;
lineIndicator.animate().x(center_point - lineIndicator.getWidth() / 2);
if (days.size() > dayListIndex && days.get(dayListIndex)!=0) {
//listener
} else {
for (int i = 0; i < 7; i++) {
dayListIndex = selectedPageIndex * 7 + i;
if (days.get(dayListIndex)==1 || days.size()-1 == dayListIndex) {
setSelectedDay(i);
break;
}
}
}
}
/**
* #param dayIndex 0-6
*/
public void setSelectedDay(int dayIndex) {
if (dayIndex >= 0 && dayIndex < 7) {
selectedDayIndex = dayIndex;
View view = daysPager.findViewWithTag(selectedPageIndex);
selectDay(view.findViewById(DAY_TV_RES_ID[dayIndex]),dayIndex);
}
}
private Runnable selectDayRunnable = new Runnable() {
#Override
public void run() {
setSelectedDay(selectedDayIndex);
}
};
}
date_tab_indicator.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="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="#+id/mon_to_sun_lay"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/mon_fixed_indicator"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_weight="1"
android:gravity="center"
android:text="M" />
<TextView
android:id="#+id/tue_fixed_indicator"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_weight="1"
android:gravity="center"
android:text="T" />
<TextView
android:id="#+id/wed_fixed_indicator"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_weight="1"
android:gravity="center"
android:text="W" />
<TextView
android:id="#+id/thu_fixed_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_weight="1"
android:gravity="center"
android:text="T" />
<TextView
android:id="#+id/fri_fixed_indicator"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_weight="1"
android:gravity="center"
android:text="F" />
<TextView
android:id="#+id/sat_fixed_indicator"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_weight="1"
android:gravity="center"
android:text="S" />
<TextView
android:id="#+id/sun_fixed_indicator"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="10sp"
android:layout_weight="1"
android:gravity="center"
android:text="S" />
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/days_pager"
android:layout_width="match_parent"
android:layout_height="50dp" />
<View
android:id="#+id/line_indicator"
android:layout_width="15dp"
android:layout_height="3dp"
android:padding="5dp"
android:background="#000000"
/>
</LinearLayout>
days_pager_item.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:gravity="center"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/day_mon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/day_circle_bg"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/day_color_selector" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/day_tue"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/day_circle_bg"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/day_color_selector" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/day_wed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/day_circle_bg"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/day_color_selector" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/day_thu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/day_circle_bg"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/day_color_selector" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/day_fri"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/day_circle_bg"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/day_color_selector" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/day_sat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/day_circle_bg"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/day_color_selector" />
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:id="#+id/day_sun"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/day_circle_bg"
android:gravity="center"
android:layout_gravity="center"
android:textColor="#color/day_color_selector" />
</FrameLayout>
</LinearLayout>
days_color_selector.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true" android:color="#000000"></item>
<item android:state_selected="false" android:color="#bdbebd"></item>
</selector>
days_circle_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<size
android:width="40dp"
android:height="40dp" />
<stroke android:width="1dp"
android:color="#bdbebd"
/>
</shape>
MainActivity.java
public class MainActivity extends AppCompatActivity {
private DateTabIndicator dateTabIndicator;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dateTabIndicator = findViewById(R.id.date_tab_indicator);
dateTabIndicator.setDays(Arrays.asList(new Integer[]{0,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}));
}
}
activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<com.karacken.datetabindicator.DateTabIndicator
android:id="#+id/date_tab_indicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
/>
</RelativeLayout>
Output:
How to build a Horizontal ListView with RecyclerView?
check the answer of "Suragch" and plus addition to that answer
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="10dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
//use your entire xml code here plus place a image view as
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below = "id of the date circle"
android:background = "add a line of length according to your requirement in drawables and assign here"
android:visibility="set to invisible"/>
/RelativeLayout>
then inside of onClick() method inside ViewHolder class set the visibilty of the ImageView to visible by Calling imageView.setVisibility(View.VISIBLE) and callnotifyDataSetChanged()
Hope it is helping...
You can change indicator position by trigger the RecycleView item selected change. For item selected change, you can use a variable to keep the selected position in adapter. When user fling the RecycleView, use have calculate selected position based on position of indicator.
I have Pager Adapter that initialize Fragment list. Problem is that Fragment loading very slow. It has delay of couple seconds, than start do load data.
I have parsed data from URL in AsyncTask doInBackground() and worked with UI in AsyncTask onPosteExecute()
Here is my Fragment:
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
readBundle(getArguments());
v = inflater.inflate(R.layout.fragment_fragment1, container, false);
new asyncTekstovi().execute(result);
return v;
}
public class asyncTekstovi extends AsyncTask<String, ArrayList<String>, ArrayList<String>> {
String result;
#Override
protected ArrayList<String> doInBackground(String... params)
{
try {
result = Ion.with(getActivity().getApplicationContext())
.load(FragmentNewsReader.this.result)
.asString()
.get();
} catch (Exception e){
e.printStackTrace();
}
String pasusUTekstu="";
if (result != null){
String htmlStringTekst=result.substring(result.indexOf("<!-- BEGIN .shortcode-content -->"), result.length());
int startPositionTekst=htmlStringTekst.indexOf("<div class=\"shortcode-content\">");
int endPositionTekst=startPositionTekst+"<div class=\"shortcode-content\">".length();
while(htmlStringTekst.substring(startPositionTekst,endPositionTekst).indexOf("<!-- END .shortcode-content -->")<0){
endPositionTekst++;
}
htmlStringTekst=htmlStringTekst.substring(startPositionTekst,endPositionTekst);
//System.out.println("vladica:"+htmlStringTekst.length()+htmlStringTekst);
int poc1;
int kraj1;
while((poc1=htmlStringTekst.indexOf("<div id"))>=0){
//System.out.println("poc1="+poc1);
kraj1=poc1+"<div id".length();
while(htmlStringTekst.substring(poc1,kraj1).indexOf(">")<0){
//System.out.println("seckanje:"+htmlStringTekst.substring(poc1,kraj1));
kraj1++;
}
htmlStringTekst=htmlStringTekst.replace(htmlStringTekst.substring(poc1,kraj1),"<p>");
}
while((poc1=htmlStringTekst.indexOf("<p "))>=0){
kraj1=poc1+"<p ".length();
while(htmlStringTekst.substring(poc1,kraj1).indexOf(">")<0){
kraj1++;
}
htmlStringTekst=htmlStringTekst.replace(htmlStringTekst.substring(poc1,kraj1),"<p>");
}
htmlStringTekst=htmlStringTekst.replace("<div id","<p>");
htmlStringTekst=htmlStringTekst.replace("</div>","</p>");
htmlStringTekst=htmlStringTekst.replace(" ","");
while(htmlStringTekst.length()>0){
startPositionTekst=htmlStringTekst.indexOf("<p>");
if(startPositionTekst>=0){
startPositionTekst+="<p>".length();
endPositionTekst=startPositionTekst;
while (htmlStringTekst.substring(startPositionTekst, endPositionTekst).indexOf("</p>") < 0) {
endPositionTekst++;
}
if(pasusUTekstu.indexOf("<img")<0) {
if(pasusUTekstu.length()>5) pasusUTekstu+="\n\n";
pasusUTekstu += htmlStringTekst.substring(startPositionTekst, endPositionTekst); //e sad ja...
}
else {
pasusUTekstu=htmlStringTekst.substring(startPositionTekst,endPositionTekst);
}
htmlStringTekst = htmlStringTekst.substring(endPositionTekst);
pasusUTekstu = pasusUTekstu.replace("<strong>", "");
pasusUTekstu = pasusUTekstu.replace("</strong>", "");
int poc=pasusUTekstu.indexOf("<img");
int zastavica=0;
if(poc>=0) zastavica=1;
while(poc>=0) {
int kraj = poc;
while (pasusUTekstu.substring(poc, kraj).indexOf("/>") < 0) {
kraj++;
}
String link = pasusUTekstu.substring(poc, kraj);
pasusUTekstu = pasusUTekstu.replace(link, "");
poc = pasusUTekstu.indexOf("<img");
}
poc=pasusUTekstu.indexOf("<a href=");
while(poc>=0) {
int kraj = poc;
while (pasusUTekstu.substring(poc, kraj).indexOf(">") < 0) {
kraj++;
}
String link = pasusUTekstu.substring(poc, kraj);
pasusUTekstu = pasusUTekstu.replace(link, "");
poc = pasusUTekstu.indexOf("<a href=");
}
pasusUTekstu=pasusUTekstu.replace("&","&");
pasusUTekstu=pasusUTekstu.replace("–","-");
pasusUTekstu=pasusUTekstu.replace("“","\"");
pasusUTekstu=pasusUTekstu.replace("”","\"");
pasusUTekstu=pasusUTekstu.replace("<p>","");
pasusUTekstu=pasusUTekstu.replace("</a>","");
pasusUTekstu=pasusUTekstu.replace("<br />","");
pasusUTekstu=pasusUTekstu.replace("</p>","");
pasusUTekstu=pasusUTekstu.replace(" ","");
pasusUTekstu=pasusUTekstu.replace("\n\n\n","\n");
//pasusUTekstu=pasusUTekstu.replace("\n\n","\n");
//System.out.println("pocetak je:"+ pasusUTekstu);
if(zastavica==1) {
if(pasusUTekstu.substring(pasusUTekstu.length()-2).equals("\n\n")) pasusUTekstu=pasusUTekstu.substring(0,pasusUTekstu.length()-2);
listaTeksta.add(pasusUTekstu);
pasusUTekstu="";
zastavica=0;
}
}
else break;
}
}
if(pasusUTekstu.length()>5) listaTeksta.add(pasusUTekstu);
return listaTeksta;
}
#Override
protected void onPostExecute(ArrayList<String> result) {
String rezultat = "";
for(int i=0;i<listaSlika.size() ;i++) {
v.findViewById(mLayoutIdArray[i]).setVisibility(View.VISIBLE);
}
for(int i=0;i<result.size();i++) {
textTv[i] = (TextView) v.findViewById(nizTekstaID[i]);
textTv[i].setText(result.get(i));
}
}
protected void onPreExecute() {
}
}
Here is my XML:
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/vestGlavnaSlikaLayout"
android:layoutDirection="ltr"
android:elevation="10dp">
<ImageView
android:id="#+id/glavnaSlika"
android:layout_width="match_parent"
android:fitsSystemWindows="false"
android:scaleType="fitXY"
android:focusable="false"
android:cropToPadding="false"
android:adjustViewBounds="true"
android:layout_alignParentBottom="false"
android:layout_alignParentRight="false"
android:layout_alignParentEnd="false"
android:layout_height="wrap_content" />
<LinearLayout
android:id="#+id/layouttekstglavnevesti1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:drawable/screen_background_dark_transparent"
android:padding="0dp">
<TextView
android:id="#+id/naslovglavni"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:maxLines="2"
android:padding="10dp"
android:textColor="#android:color/background_light"
android:textSize="36sp" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/lazoutZaNaslove"
android:layout_marginBottom="15dp"
android:layout_marginLeft="#dimen/h"
android:layout_marginRight="#dimen/h"
android:layout_marginTop="-10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/prednaslov"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#android:color/darker_gray"
android:layout_marginLeft="-40dp" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/naslov1"
android:textSize="20sp"
android:textColor="#android:color/black"
android:textStyle="normal|bold" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/podnaslov"
android:textColor="#android:color/black"
android:textSize="15sp"
android:textStyle="normal|bold" />
</LinearLayout>
<include
layout="#layout/activity_slikatext1"
android:id="#+id/includedLayout"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/h"
android:layout_marginRight="#dimen/h"
android:layout_below="#id/lazoutSlikaTekst" />
<include
layout="#layout/activity_slikatext2"
android:id="#+id/includedLayout1"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/h"
android:layout_marginRight="#dimen/h"
android:layout_below="#id/includedLayout" />
<include
layout="#layout/activity_slikatext3"
android:id="#+id/includedLayout2"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/h"
android:layout_marginRight="#dimen/h"
android:layout_below="#id/includedLayout1" />
<include
layout="#layout/activity_slikatext4"
android:id="#+id/includedLayout3"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/h"
android:layout_marginRight="#dimen/h"
android:layout_below="#id/includedLayout2" />
<include
layout="#layout/activity_slikatext5"
android:id="#+id/includedLayout4"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/h"
android:layout_marginRight="#dimen/h"
android:layout_below="#id/includedLayout3" />
Change this code to onViewCreated() method
new asyncTekstovi().execute(result);
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));
}
I want to display the video thumbnails in listview, I use images instead of thumbnails and add ImageView (image play button) on the front but failed my xml code like this
<?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="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/txttgl"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:paddingLeft="10dip"
android:gravity="center_horizontal"/>
<TextView
android:id="#+id/tv_batas_unread"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:paddingLeft="12dip"
android:background="#drawable/counter_shape_birudonker"
android:visibility="gone"
android:gravity="center_horizontal"/>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/ll_chat_item"
android:orientation="horizontal" >
<com.ltvie.chatkrawala.ImageViewRounded
android:id="#+id/img_photo_pp_chatbox"
android:layout_width="50dp"
android:layout_height="50dp"
android:paddingBottom="0dp"
android:paddingLeft="2dp"
android:paddingRight="2dp"
android:adjustViewBounds="true"
android:paddingTop="0dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="3dp"
android:src="#drawable/gada_photo"
android:scaleType="fitXY" />
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="left"
android:orientation="vertical"
android:layout_marginBottom="12dp"
android:layout_weight="1"
android:cacheColorHint="#android:color/transparent"
>
<TextView
android:id="#+id/txtKodeGbr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<TextView
android:id="#+id/txtPesan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"/>
<TextView
android:id="#+id/comment"
android:layout_marginTop="9dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/buble_kiri"
android:text="Bismillahirohmanirrohim"
android:textColor="#000"
android:textSize="15sp" />
<LinearLayout
android:id="#+id/rowFile"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:layout_height="match_parent"
android:layout_width="wrap_content"
>
<ImageView
android:id="#+id/img_dilvChat"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="3dp"
android:contentDescription="#string/descGambar"
android:background="#drawable/buble_kanan"
android:src="#drawable/gada_photo"
/>
<ImageView
android:id="#+id/img_btn_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="#string/descGambar"
android:layout_centerInParent="true"
android:src="#drawable/play_icon"
/>
<ProgressBar
android:id="#+id/chatBox_progress_img"
style="?android:attr/progressBarStyleSmallInverse"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
<LinearLayout
android:id="#+id/rowFileDesc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:layout_gravity="bottom"
android:orientation="vertical">
<TextView
android:id="#+id/txtFileName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:gravity="left"
android:text="Nama File : test.zip"
android:textSize="12sp" />
<TextView
android:id="#+id/txtFileSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:gravity="left"
android:text="Ukuran : 2324342 bytes"
android:textSize="12sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/img_statusBaca"
android:layout_marginTop="2dip"
android:layout_width="15dip"
android:layout_height="15dip"
android:layout_marginRight="1dip"
android:background="#drawable/indicator_sending"
android:contentDescription="#string/descGambar"
/>
<TextView
android:id="#+id/txtjamchatMasuk"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dip"
android:gravity="left"
android:text="setatus baca"
android:textSize="12sp" />
<TextView
android:id="#+id/txtKiriKanan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:text="right"
android:visibility="gone"
/>
</LinearLayout>
</LinearLayout>
<ImageView
android:id="#+id/imgselected"
android:layout_width="20dp"
android:layout_height="20dp"
android:contentDescription="#string/kosongan"
android:src="#drawable/ico_member" />
</LinearLayout>
</LinearLayout>
my java code
public class ChatboxArrayAdapter extends ArrayAdapter<OneComment> implements SectionIndexer{
private TextView countryName;
private LinearLayout wrapper,rowFileDesc,ll_chat_item;
private TextView TanggalMasuk,txtKodeGbr,txtPesan,txtJam,txtKiriKanan,txtUkuranFile;
private ImageView img_upload,img_statusbaca,imgPp_round;
ImageView imgPhoto,imgCheck,imgBtnPlay;
String namafileGambar,strPath,varStsBaca,tampilTgl;
public CacheImageLoader imageLoader;
Context ctx;
Options opts = new BitmapFactory.Options();
String TAG="chatboxArrayAdapter";
File dir = new File(Environment.getExternalStorageDirectory()+"");
File dirImage=new File(dir+"/a");
File dirVideo=new File(dir+"/a");
List<OneComment> countries;
#Override
public void add(OneComment object) {
countries.add(object);
super.add(object);
}
public void hapus_semua(){
countries.clear();
}
public void hapus_item(int nomerx){
countries.remove(nomerx);
notifyDataSetChanged();
}
public void refresh_lv(){
notifyDataSetChanged();
Log.d("notify", "datachange");
}
public ChatboxArrayAdapter(Context context, int textViewResourceId, List<OneComment> datanya) {
super(context, textViewResourceId);
this.countries=datanya;
this.ctx=context;
imageLoader=new CacheImageLoader(context.getApplicationContext());
}
public int getCount() {
return this.countries.size();
}
#Override
public OneComment getItem(int index) {
return this.countries.get(index);
}
public View getView(final int position, View convertView, ViewGroup parent) {
View row = convertView;
try{
if (row == null) {
LayoutInflater inflater = (LayoutInflater) this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
row = inflater.inflate(R.layout.chatbox_detail, parent, false);
}
OneComment isiOneComen = getItem(position);
wrapper = (LinearLayout) row.findViewById(R.id.wrapper);
rowFileDesc=(LinearLayout) row.findViewById(R.id.rowFileDesc);
ll_chat_item=(LinearLayout) row.findViewById(R.id.ll_chat_item);
imgPhoto = (ImageView) row.findViewById(R.id.img_dilvChat);
countryName = (TextView) row.findViewById(R.id.comment);
txtKiriKanan = (TextView) row.findViewById(R.id.txtKiriKanan); //isi dari coment untuk menentukan letak buble di kiri ato dikanan,hanya untuk buble file untuk menentukan filenya masih di server apa sudah di downloa
TanggalMasuk= (TextView) row.findViewById(R.id.txttgl);
img_upload=(ImageView) row.findViewById(R.id.img_dilvChat);
txtKodeGbr = (TextView) row.findViewById(R.id.txtKodeGbr);
txtPesan=(TextView) row.findViewById(R.id.txtPesan);
txtJam=(TextView) row.findViewById(R.id.txtjamchatMasuk);
txtUkuranFile=(TextView) row.findViewById(R.id.txtFileSize);
imgCheck=(ImageView) row.findViewById(R.id.imgselected);
img_statusbaca=(ImageView) row.findViewById(R.id.img_statusBaca);
imgPp_round=(ImageView) row.findViewById(R.id.img_photo_pp_chatbox);
imgBtnPlay=(ImageView) row.findViewById(R.id.img_btn_play);
txtPesan.setVisibility(View.GONE);
txtKodeGbr.setVisibility(View.GONE);
img_upload.setVisibility(View.GONE);
rowFileDesc.setVisibility(View.GONE);
if(isiOneComen.comment.trim().equalsIgnoreCase("video")){
//error goes here
countryName.setVisibility(View.GONE);
Log.d("fileDesc", isiOneComen.Filedesc);
//strPath = namafileGambar;
strPath = moduleGlobal.dirImageSent+"/"+isiOneComen.Filedesc;
imgPhoto.setImageBitmap(changeSize(strPath));
scaleImage(imgPhoto, ((int) isiOneComen.lebarScreen)-((int) isiOneComen.lebarScreen/4));
imgBtnPlay.setVisibility(View.VISIBLE);
}else{ //run work well
countryName.setVisibility(View.VISIBLE);
try{
countryName.setText(getSmiledText(getContext(),isiOneComen.comment.toString()));
}catch (Exception e) {
// TODO: handle exception
Log.e("addsmiley", e.toString());
}
countryName.setBackgroundResource(isiOneComen.left ? R.drawable.buble_kiri : R.drawable.buble_kanan);
}
}catch (Exception ez) {
ll_chat_item.setVisibility(View.GONE);
Log.e(TAG, ez.toString());
}
return row;
}
private Bitmap changeSize(String path){
opts.inSampleSize = 1;
Bitmap bm = BitmapFactory.decodeFile(path);
if (bm.getHeight() > 150 || bm.getWidth() > 150) {
final int halfHeight = bm.getHeight() / 2;
final int halfWidth = bm.getWidth() / 2;
// Calculate the largest inSampleSize value that is a power of 2 and keeps both
// height and width larger than the requested height and width.
while ((halfHeight / opts.inSampleSize) > 150
&& (halfWidth / opts.inSampleSize) > 150) {
opts.inSampleSize *= 2;
}
}
bm = BitmapFactory.decodeFile(path,opts); // this bitmap will be 1/8 the size of the original
return bm;
}
private void scaleImage(ImageView view, int boundBoxInDp)
{
// Get the ImageView and its bitmap
Drawable drawing = view.getDrawable();
Bitmap bitmap = ((BitmapDrawable)drawing).getBitmap();
// Get current dimensions
int width = bitmap.getWidth();
int height = bitmap.getHeight();
// Determine how much to scale: the dimension requiring less scaling is
// closer to the its side. This way the image always stays inside your
// bounding box AND either x/y axis touches it.
float xScale = ((float) boundBoxInDp) / width;
float yScale = ((float) boundBoxInDp) / height;
float scale = (xScale <= yScale) ? xScale : yScale;
// Create a matrix for the scaling and add the scaling data
Matrix matrix = new Matrix();
matrix.postScale(scale, scale);
// Create a new bitmap and convert it to a format understood by the ImageView
Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
#SuppressWarnings("deprecation")
BitmapDrawable result = new BitmapDrawable(scaledBitmap);
width = scaledBitmap.getWidth();
height = scaledBitmap.getHeight();
// Apply the scaled bitmap
view.setImageDrawable(result);
// Now change ImageView's dimensions to match the scaled image
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams();
params.width = width;
params.height = height;
view.setLayoutParams(params);
}
public Bitmap decodeToBitmap(byte[] decodedByte) {
return BitmapFactory.decodeByteArray(decodedByte, 0, decodedByte.length);
}
/**tambah smiley
*
*/
private static final HashMap<String, Integer> emoticons = new HashMap<String, Integer>();
static {
emoticons.put(":)", R.drawable.s1);
emoticons.put(":D", R.drawable.s2);
emoticons.put(":(", R.drawable.s3);
emoticons.put("8o|", R.drawable.s16);
emoticons.put(":/", R.drawable.s17);
}
// Get image for each text smiles
public static Spannable getSmiledText(Context context, String text) {
SpannableStringBuilder builder = new SpannableStringBuilder(text);
int index;
for (index = 0; index < builder.length(); index++) {
for (Entry<String, Integer> entry : emoticons.entrySet()) {
int length = entry.getKey().length();
if (index + length > builder.length())
continue;
if (builder.subSequence(index, index + length).toString().equals(entry.getKey())) {
builder.setSpan(new ImageSpan(context, entry.getValue()), index, index + length,
Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
index += length - 1;
break;
}
}
}
return builder;
}
#Override
public int getPositionForSection(int arg0) {
// TODO Auto-generated method stub
return 0;
}
#Override
public int getSectionForPosition(int arg0) {
// TODO Auto-generated method stub
return 0;
}
#Override
public Object[] getSections() {
// TODO Auto-generated method stub
return null;
}
}
everything work well before i add relative layout,I want to add image view center with other imageview but I get error log
java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
Problem with
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) view.getLayoutParams();
This line Change this line to
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) view.getLayoutParams();
Because you forgot to Add
</LinearLayout>
</LinearLayout>
at the end of your xml.
Use this
<?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="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tv1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:gravity="center_horizontal"
android:paddingLeft="10dip" />
<LinearLayout
android:id="#+id/ll_chat_item"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/tv2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<LinearLayout
android:id="#+id/wrapper"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp"
android:layout_weight="1"
android:cacheColorHint="#android:color/transparent"
android:gravity="left"
android:orientation="vertical" >
<TextView
android:id="#+id/tv3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
<LinearLayout
android:id="#+id/rowFile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/img_dilvChat"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_margin="3dp"
android:background="#drawable/buble_kanan"
android:contentDescription="#string/descGambar" />
<ImageView
android:id="#+id/img_btn_play"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:contentDescription="#string/descGambar"
android:src="#drawable/play_icon" />
</RelativeLayout>
<TextView
android:id="#+id/tv4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dip"
android:gravity="center_horizontal"
android:paddingLeft="10dip" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>