I have 2 EditText's in a layout. For some reason, the border outline that shows in the preview here(http://gyazo.com/7cb0d1d2c5807e65f65164957b4d13b8) doesn't show when I run the app on my phone or on the emulator(http://gyazo.com/428bb31a974e43ccb52aaaee61f3b355). I would like to see that box that outlines the Edittext's in the preview screen.
If anyone could try and see what the issue is, that would be great, thanks.
XML containing the 2 Edittext's:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/background_medium"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".List" >
<LinearLayout
android:id="#+id/Text1andText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:layout_weight="50"
android:ems="10"
android:hint="#string/Text2" />
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="110dp"
android:layout_weight="50"
android:ems="10"
android:hint="#string/Text2" />
</LinearLayout>
</LinearLayout>
This is a Theme problem. Your device is using Holo Theme. Try to change your Theme as desire (ui.light /ui.dark)in your application manifest.
Related
In my app, I have some spinners (each of which is part of a fragment) in a scrollView. This scrollView is placed below a textView.
The problem is that, when I'm running the app on my test device (Samsung Galaxy S6 Edge [G925F], API 23), the little arrow of the spinner stays visible above the textView, even though the rest of the spinner is already out of view.
I did a lot of research but couldn't find any solutions, so I'm asking here:
What do I need to do so that the arrows disappear like the rest of the spinner?
Here some pictures:
In this picture, you can see the textView at the top of the activity and below the spinners, before I scrolled down
In this screenshot, you can see the problem. The little triangles of the spinner are still visible, but the spinner itself is already scrolled out of view.
Here is the XML code of the fragment containing the spinner:
<?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">
<LinearLayout
android:id="#+id/fragLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/gradeDisplay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:layout_marginLeft="15dp"
android:text="1"
android:textSize="30dp"/>
<Spinner
android:id="#+id/spinner"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:entries="#array/grades"/>
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:layout_marginEnd="15dp"
android:layout_marginRight="15dp"
android:src="#drawable/ic_remove_black_24dp"
android:background="#null"/>
</LinearLayout>
<Space
android:layout_width="0dp"
android:layout_height="5dp"
android:layout_below="#id/fragLayout"/>
</RelativeLayout>
And here is the code of the MainActivitys content:
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="de.jeanma.android.avo.MainActivity"
tools:showIn="#layout/activity_main">
<Space
android:id="#+id/mainContentSpace"
android:layout_width="match_parent"
android:layout_height="16dp" />
<TextView
android:id="#+id/textView"
android:layout_below="#id/mainContentSpace"
android:layout_width="match_parent"
android:text="Standard text"
android:layout_height="wrap_content"
android:textSize="40dp"
android:gravity="end"/>
<ScrollView
android:id="#+id/scrollView"
android:layout_below="#id/textView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/divider"
android:showDividers="middle">
</LinearLayout>
</ScrollView>
</RelativeLayout>
The fragments are added to the LinearLayout (#id/layout) by a Java method. If needed, I will post that here as well.
I'm using Java 1.8.05 and the target SDK is 23, the minimum is 14. The code is written in Android Studio
The textView with the problems is the #id/textView, displaying the large number at the top.
#jeanma you can fix the issue with just setting
android:background="#00FFFFFF"
for your ScrollView or root LinearLayout of the ScrollView
I now have got a workaround running. As suggested as I set the textView's backgroundcolor the same as my activity, the arrrows wheren't showing any longer. But the space did behave difrently. There it han'd changed somethinf that I changed the backgroundcolor. So I just removed it. (It still looks kinda good).
The updated XML-file od the MainActivity'a content can be seen here:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="de.jeanma.android.avo.MainActivity"
tools:showIn="#layout/activity_main">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:text="Standard text"
android:layout_height="wrap_content"
android:textSize="40dp"
android:gravity="end"
android:background="#FAFAFA"/>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView">
<LinearLayout
android:id="#+id/layout"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:divider="#drawable/divider"
android:showDividers="middle">
</LinearLayout>
</ScrollView>
</RelativeLayout>
But because the arrows were showing threw the padding as well, I changed my
src\main\res\values\dimens.xml to the following (I know that that's really bad practice):
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">0dp</dimen><!-- This was changed from 16dp to 0dp -->
<dimen name="fab_margin">16dp</dimen>
</resources>
Thanks #ScriptKity #Wukash #Bryan for your support
Set Background Color in your parent layout.
android:background="#color/white"
I've run into this problem recently, and believe this is a bug in the hardware accelerated rendering on Android when you combine ScrollView and Spinner.
I was able to fix this by turning the hardware acceleration off for the Spinner(s):
mySpinner.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
Other possibilities how to control the hardware acceleration are described here:
https://developer.android.com/guide/topics/graphics/hardware-accel
I have strange problem. When I set Text Alignment of my EditText to center the keyboard is not lifting it up. EditText stays behind the keyboard ( is hidden). Why is that? What I should do to lift the EditText above the keyboard. EditText is placed in LinearLayout and that all is placed in FrameLayout at the bottom. Thank you!
Edit (code of layout):
<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="match_parent"
tools:context=".ProfileChooseActivity"
android:scrollIndicators="none"
android:background="#drawable/bg_run4">
<!-- The primary full-screen view. This can be replaced with whatever view
is needed to present your content, e.g. VideoView, SurfaceView,
TextureView, etc. -->
<!-- This FrameLayout insets its children based on system windows using
android:fitsSystemWindows. -->
<LinearLayout
android:orientation="vertical"
android:layout_width="233dp"
android:layout_height="159dp"
android:layout_gravity="start|bottom"
android:layout_margin="10dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/profileNameEditText"
android:layout_margin="10dp"
android:backgroundTint="#97f8720b"
android:hint="#string/profile_name"
android:textCursorDrawable="#null"
android:layout_marginTop="20dp"
android:textColor="#3d3131"
android:textAlignment="center"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/enter_profile"
android:id="#+id/enterProfileButton"
android:layout_gravity="center_horizontal"
android:background="#97f8720b"
android:singleLine="false"
android:clickable="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
/>
</LinearLayout>
</FrameLayout>
I replicated the layout file as you described and everything is working. May be there is a problem with your layout.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<EditText
android:id="#+id/edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:textAlignment="center"/>
</LinearLayout>
</FrameLayout>
I am making an app where there is a custom search bar. I want there to be a search part that is big, a spinner for region selection that is a small square, and a search button that is also a small square.
Here is what I am talking about.
The code I have right now is this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<EditText
android:hint="#string/summoner_name"
android:layout_width="wrap_content"
android:layout_weight="75"
android:layout_height="wrap_content"
android:id="#+id/summoner_name"/>
<Spinner
android:layout_weight="1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/regions">
</Spinner>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/search_button"/>
</LinearLayout>
However, this makes the search half the screen, and the button for 2/5's the screen, and the spinner for a smaller ammount. Anyone know how to accomplish this?
Thanks :)
give weight 1 to EditText android:layout_weight="1" , and remove weight tags from other components.
Also you will require to set Spinners width statically, if above doesnt work because of Spinner's width part
like this?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin" tools:context=".MainActivity"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:layout_width="wrap_content"
android:layout_weight="75"
android:layout_height="wrap_content"
android:id="#+id/summoner_name"/>
<Spinner
android:layout_weight="1"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:id="#+id/regions"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/search_button"/>
</LinearLayout>
</LinearLayout>
I'm fiddling around with writing android apps and what I'm currently trying to do is to have a text box with a send button at the top of the page and a black button bar at the bottom.
I understand from this question that the correct way to do this would be to write something like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<LinearLayout
android:layout_height="wrap_content"
<EditText android:id="#+id/edit_message"
android:layout_weight="1"
android:layout_width="0dp"
android:hint="#string/edit_message"
android:layout_gravity="top|center"/>
<Button
android:layout_width="wrap_content"
android:text="#string/button_send"
android:onClick="sendMessage"/>
</LinearLayout>
<LinearLayout android:id="#+id/footer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
style="#android:style/ButtonBar">
<Button android:id="#+id/saveButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/menu_done" />
<Button android:id="#+id/cancelButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/menu_cancel" />
</LinearLayout>
</LinearLayout>
but the black bar and the text box just end up on top of each other :(
I'm not sure if these are cut-and-past errors, but I noticed a few things in the xml. The first nested linear layout is missing a '>' before the EditText and doesn't specify a layout_height. And the first button also doesn't have a layout_height.
There is a very high possibility that a question similar to this has been asked earlier, but I couldn't figure out the related keywords to find the same.
I am making an application, and the layout I designed is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".Scheduler" >
<EditText
android:id="#+id/addressee"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="#string/addresseeHint"
android:inputType="number" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="2" >
<EditText
android:id="#+id/date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/scheduleDate"
android:inputType="date" />
<EditText
android:id="#+id/time"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="#string/scheduleTime"
android:inputType="time" />
</LinearLayout>
<EditText
android:id="#+id/smsText"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="top"
android:hint="#string/smsTextHint"
android:inputType="text" />
<Button
android:id="#+id/scheduleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:text="#string/scheduleTextButton" />
</LinearLayout>
The layout which appears is as below:
What I want will look something like this:
The problem is the Button at the bottom (id:scheduleText) disappears, reason being the layout_height parameter of the EditText set just above it is fill_parent. But I guess I can't provide any particular value to it as then the layout will look different on different devices ?
How can I fix this bug ?
Thanks
Hi your EditText has a height of fill parent which makes it fill the parent and the button won't be visible so make it like this:
<EditText
android:id="#+id/smsText"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="top"
android:hint="#string/smsTextHint"
android:inputType="text" />
UPDATE:
I updated the answer to extend the edit text and fill the screen but let space for the button as well. The trick is to use weight..