Different tab width for TabLayout

You need to lower the weight of the LinearLayout of the corresponding tab. LinearLayout layout = ((LinearLayout) ((LinearLayout) tabLayout.getChildAt(0)).getChildAt(YOUR_TAB_NUMBER)); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) layout.getLayoutParams(); layoutParams.weight = YOUR_WEIGHT; // e.g. 0.5f layout.setLayoutParams(layoutParams); Hope that helps!

Take photo from camera in fragment

Hope this will help you: public class CameraImage extends Fragment { private static final int CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE = 1888; Button button; ImageView imageView; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.camera_image, container, false); button = (Button) rootView.findViewById(R.id.button); imageView = (ImageView) rootView.findViewById(R.id.imageview); button.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) … Read more

Disable multi finger touch in my app [duplicate]

For case: you have multiple buttons and you want make selected only one button. In parent (NOT ROOT, just parent of child) of buttons, in its xml params add android:splitMotionEvents=”false” And that’s it. Example: <LinearLayout android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:orientation=”horizontal” android:splitMotionEvents=”false” <———–!!! > <Button android:id=”@+id/button_main_1″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”button1″ /> <Button android:id=”@+id/button_main_2″ android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:text=”button2″ /> <Button android:id=”@+id/button_main_3″ … Read more

Pop up window to display some stuff in a fragment

The following should work perfect in accordance with your specification. Call this method from inside onClick(View v) of OnClickListener assigned to the View: public void showPopup(View anchorView) { View popupView = getLayoutInflater().inflate(R.layout.popup_layout, null); PopupWindow popupWindow = new PopupWindow(popupView, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); // Example: If you have a TextView inside `popup_layout.xml` TextView tv = (TextView) popupView.findViewById(R.id.tv); tv.setText(….); … Read more

Android Two Fragments in Same Activity

Do the following: Change Fragment to FrameLayout in the main activity XML, for both. Change layout_width from fill_parent to match_parent, for both FrameLayout in the main XML file, (ones created in step 1). Change layout_height from fill_parent to wrap_content, for both FrameLayout in the main XML file, (ones created in step 1). Change FrameLayout to … Read more

FragmentStatePagerAdapter with ChildFragmentManager – FragmentManagerImpl.getFragment results in NullPointerException

I would need to see more code in order to know where to apply this … but I had a similar situation as you did… I solved the ChildFragmentManager issue the same way, and got the same NullPointerException, as you have. I did manage to solve it… I’ll try to describe my solution, as with … Read more

FragmentActivity can not be tested via ActivityInstrumentationTestCase2

I spent half the night on this, and finally found a solution. The key line is: 04-05 18:00:11.276, (Lcom/example/android/app/FragmentLayoutSupport; had used a different Landroid/support/v4/app/FragmentActivity; during pre-verification). The problem is that the android-support-v4.jar which you are using in your test project is different from that one in your application project. Remove all of the references to … Read more