layout_margin in CardView is not working properly

If you use RecyclerView to add CardView, android:layout_margin should be sufficient. But using ListView to add CardView, you might do this: <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”wrap_content” > <android.support.v7.widget.CardView xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_marginLeft=”11dp” android:layout_marginRight=”11dp” android:layout_marginTop=”11dp”> (other layout …) </android.support.v7.widget.CardView> </FrameLayout> But it is usually not the optimal one.

How to load fragment data only when its tab is clicked in PagerSlidingTabStrip

You could override setUserVisibleHint event of the fragment to know if its visible to the user and then load your data. something like following: boolean _areLecturesLoaded = false; @Override public void setUserVisibleHint(boolean isVisibleToUser) { super.setUserVisibleHint(isVisibleToUser); if (isVisibleToUser && !_areLecturesLoaded ) { loadLectures(); _areLecturesLoaded = true; } }

Swipe one item at a time Recyclerview [duplicate]

This softens the movement between items: public class SnapHelperOneByOne extends LinearSnapHelper { @Override public int findTargetSnapPosition(RecyclerView.LayoutManager layoutManager, int velocityX, int velocityY) { if (!(layoutManager instanceof RecyclerView.SmoothScroller.ScrollVectorProvider)) { return RecyclerView.NO_POSITION; } final View currentView = findSnapView(layoutManager); if (currentView == null) { return RecyclerView.NO_POSITION; } LinearLayoutManager myLayoutManager = (LinearLayoutManager) layoutManager; int position1 = myLayoutManager.findFirstVisibleItemPosition(); int position2 = … Read more

FragmentPagerAdapter getItem is not being triggered

Any workaround to overcome this problem? I’ve downloaded your code and the problem appears because you don’t handle those Fragments right. Most precisely you use nested Fragments in the ViewPager based Fragment and for that ViewPager you create the adapter like this: MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(this.getFragmentManager()); Instead, you should be using getChildFragmentManager() to bind … Read more

How to add margin between EditText and Soft Keyboard?

I find the attribute of paddingBottom can effect the distance between the editText and the keyboard. You can do like this: <RelativeLayout android:layout_width=”match_parent” android:layout_height=”110dp”> <ImageView android:layout_width=”match_parent” android:layout_height=”100dp” android:background=”@drawable/your_edit_text_background”/> <EditText android:layout_width=”match_parent” android:layout_height=”match_parent” android:paddingBottom=”10dp”/> </RelativeLayout> This will make your keyboard margin your EditText by 10dp

TabLayout with viewpager not smooth scrolling

I just went through your code. The problem is that you are not providing any layout to inflate inside ContentFragment.java. I changed your method to @Nullable @Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { //return super.onCreateView(inflater, container, savedInstanceState); return inflater.inflate(R.layout.feed_item, container, false); } After making these changes your tabs were scrolling … Read more

ViewPager + FragmentPagerAdapter inside a DialogFragment gets “IllegalArgumentException:No view found…”

Try this: In class AchGalleryDialog MyFragmentAdapter adapter = new MyFragmentAdapter(getChildFragmentManager(),images); instead of MyFragmentAdapter adapter = new MyFragmentAdapter(getFragmentManager(),images); Because of this: http://developer.android.com/about/versions/android-4.2.html#NestedFragments Hope this will help!

Differentiating between user scroll and programatic page change in ViewPager

OK, so it turns out that I was right about the answer lying in ViewPager.onPageChangeListener. In particular it lies in using onPageScrollStateChanged(int state). Essentially there are three states that a page in a ViewPager can be in: Dragging: Indicates that the pager is currently being dragged by the user. Idle: Indicates that the pager is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)