android-layout

Android Tabs in middle of layout

五迷三道 提交于 2020-01-11 06:32:30
问题 In the middle of my layout I want to have 2 tabs to choose between viewing 2 different lists in the second half of the screen. How can I do this? Here is an image illustrating what I wish to achieve. This image has a questions tab and an answers tab in the middle of the screen. Depending on which tab you select it shows a different listview: I wish to achieve this exact same thing. I tried doing it with TabHost widget, but for the life of me I couldn't get rid of the title bar (I tried

How can I save my bitmap correctly for second time?

北城以北 提交于 2020-01-11 05:22:32
问题 I want to save my bitmap to cache directory. I use this code: try { File file_d = new File(dir+"screenshot.jpg"); @SuppressWarnings("unused") boolean deleted = file_d.delete(); } catch (Exception e) { // TODO: handle exception } imagePath = new File(dir+"screenshot.jpg"); FileOutputStream fos; try { fos = new FileOutputStream(imagePath); bitmap.compress(CompressFormat.JPEG, 100, fos); fos.flush(); fos.close(); } catch (FileNotFoundException e) { Log.e("GREC", e.getMessage(), e); } catch

Android RTL issue in API 24 and higher on locale change

霸气de小男生 提交于 2020-01-11 03:37:36
问题 I was trying to change locale of app at runtime. It is working fine in Andorid below API level 24. But in API level 24 or greater the layout direction is not changing according to locale. Below is the code to change the locale at runtime. I have used LocaleHelper class as below public class LocaleHelper { private static final String SELECTED_LANGUAGE = "Locale.Helper.Selected.Language"; public static Context onAttach(Context context) { String lang = getPersistedData(context, Locale.getDefault

Click through a RecyclerView list item

霸气de小男生 提交于 2020-01-11 02:09:30
问题 I have a RecyclerView with a LinearLayoutManager and an Adapter : @Override public int getItemViewType(int position) { return position == 0? R.layout.header : R.layout.item; } Here's header.xml : <View xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/header" android:layout_width="match_parent" android:layout_height="@dimen/header_height" /> What I want to achieve is to have a hole in the RecyclerView where I can click through to anything behind the RecyclerView . I

Why shouldn't I set layout_width and layout_height in a style?

醉酒当歌 提交于 2020-01-10 17:26:07
问题 If I have a lot of TextViews serving as item labels, I thought I could extract everything that's common about them into a style, and in the layout use only <TextView style="@style/label" android:text="Foo"/> <TextView style="@style/label" android:text="Bar"/> with style like: <style name="label"> <item name="android:layout_width">wrap_content</item> <item name="android:layout_height">wrap_content</item> </style> But when I do this, it works fine on emulator and device, but the Android XML

Disable auto focus on edit text

元气小坏坏 提交于 2020-01-10 06:46:55
问题 I have an edit text: <LinearLayout android:id="@+id/linearLayout7" android:layout_width="match_parent" android:layout_height="wrap_content"> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="1" android:id="@+id/editText1" android:text="3"> <requestFocus></requestFocus> </EditText> <Button android:text="Button" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/button2"></Button> </LinearLayout> and

android.content.res.Resources$NotFoundException: Resource ID #0x0 Android error

烂漫一生 提交于 2020-01-10 06:10:08
问题 I am Creating an ArrayAdapter's Super class in which I am binding the data I receive from the object and put them into the TextViews. The code is not any complicated and I have double checked the ids of all the TextViews in my XML. And I have checked all the other questions with the same title. None of them seem to work in this case. Attaching my code below. public class EarthquakeAdapter extends ArrayAdapter<Earthquake> { public EarthquakeAdapter(Context context, int resource) { super

RelativeLayout scrollview

久未见 提交于 2020-01-10 05:27:05
问题 I have an app with a few textboxes and editboxes. The app is working fine but when I am trying to add the scrollview element to see the lower part of app the application is forcibly closing. My code is: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height="fill_parent" android:layout_width="fill_parent"> <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"> <TextView android:id="@

Gradient status bar with BottomNavigationView

[亡魂溺海] 提交于 2020-01-10 05:24:06
问题 In my Application I want to show gradient status bar. Also i have used BottomNavigationView . So issue is when i am doing status bar gradient the bottom navigation bar of android overlaps the BottomNavigationView . I have tried below solutions : how to set status bar background as gradient color or a drawable in android Google Now gradient/shadow on status bar & navigation bar How to apply gradient to status bar in android? How to remove button bar at the bottom screen My code is as below : -

Lollipop capitalizes Buttons' text in my app

冷暖自知 提交于 2020-01-10 04:22:04
问题 I am expreiencing a strange problem with my application. When I am testing it on a real device (with Android 4.4.4) all my Buttons' text fields look how I wanted (lower case letters). But when I launch my application on an emulator (Android 5.0.1) all Button texts fields are capitalized. What is the reason of such behaviour? Some example Buttons from my app: Example Button 1: <Button android:id="@+id/button5" android:layout_width="match_parent" style="?android:attr/borderlessButtonStyle"