Background image does not seem to fill entire screen - java

The below picture shows that there are vertical "lines" running down the sides of each side of the screen. The background image seems to fill most of the screen but then there are these lines and the picture does not line up. See where I marked these lines with the black arrows. There seems to be no horizontal lines at the top and bottom of the screen. I cannot find any reason for this.
Below is some relevant code that might be where the problem is residing.
AndroidManifest.xml
<activity
android:label="#string/app_name"
android:name=".MainMenu"
android:screenOrientation="portrait"
android:theme="#android:style/Theme.Translucent.NoTitleBar" />
Here is a section of my styles.xml that is referenced in my AndroidManifest.xml.
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">#android:color/transparent</item>
<item name="android:windowContentOverlay">#null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
EDIT
Just to clarify, this problem occurs on all the layouts, not just the one below.
mainmenu.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relativelayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:paddingTop="5dp" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:paddingTop="75dp"
android:textSize="60sp" />
<LinearLayout
android:id="#+id/linearlayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:orientation="vertical"
android:fillViewport="true"
android:paddingTop="175dp" >
<TextView
android:id="#+id/playBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="12dp"
android:textSize="30sp"
android:background="#color/transparent"
android:textColor="#color/onclicktextviewhighlight" />
<TextView
android:id="#+id/highscoresBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginBottom="12dp"
android:textSize="30sp"
android:background="#color/transparent"
android:textColor="#color/onclicktextviewhighlight" />
<TextView
android:id="#+id/optionsBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textSize="30sp"
android:background="#color/transparent"
android:textColor="#color/onclicktextviewhighlight" />
</LinearLayout>
</RelativeLayout>

because you have padding in your layout
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingBottom="5dp"
android:paddingTop="5dp"

The padding. Like tyczj said. Also there IS a horizontal line

Related

Android 7.0 showing TextView Inflating error

My XML CODE:-
<?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:background="#android:color/white"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<TextView
android:id="#+id/tvCollege"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:text="NGF\nCOLLEGE"
android:textColor="#android:color/black" />
<TextView
android:id="#+id/tvNameTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:layout_toLeftOf="#id/imgBarTeachers"
android:layout_toRightOf="#id/tvCollege"
android:gravity="center"
android:textAllCaps="true"
android:textColor="#color/colorAccent"
android:textSize="18sp" />
<ImageView
android:id="#+id/imgBarTeachers"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/ic_menu" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="10dp"
android:paddingTop="20dp"
android:paddingRight="10dp"
android:paddingBottom="20dp">
<ImageView
android:layout_width="96dp"
android:layout_height="96dp"
android:padding="10dp"
android:src="#drawable/ic_teachers" />
<View
android:layout_width="1dp"
android:layout_height="76dp"
android:layout_gravity="center_vertical"
android:layout_marginLeft="9dp"
android:layout_marginRight="9dp"
android:background="#android:color/black" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/tvSubjectTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAllCaps="true"
android:textColor="#414141"
android:textSize="18sp" />
<TextView
android:id="#+id/tvMobileTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
<TextView
android:id="#+id/tvMailTeacher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#android:color/black" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerViewMenuTeacher"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
</LinearLayout>
My app is running perfectly but when I'm running my app in android 7.0 it's showing me this error.
Error what I'm getting:
Process: com.ngfcet.ngfconnection, PID: 21684
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ngfcet.ngfconnection/com.ngfcet.ngfconnection.activities.TeacherActivity}: android.view.InflateException: Binary XML file line #21: Binary XML file line #21: Error inflating class TextView
I think this error is also can formed by firebase because
which textview have +id/tvCollege is not showing any error because I'm not putting any data in it through firebase
Theme for whole application
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowLightStatusBar" tools:targetApi="m">true</item>
<item name="android:statusBarColor" tools:targetApi="lollipop">#android:color/white</item>
<item name="android:windowLightNavigationBar" tools:targetApi="o_mr1">true</item>
<item name="android:navigationBarColor" tools:targetApi="lollipop">#android:color/white</item>d
<item name="android:fontFamily">sans-serif-medium</item>
</style>
</resources>
It's too simple. I have removed
<item name="android:fontFamily">sans-serif-medium</item>
from styles.xml
Thanks! It's working perfect now

Textviews at the end of screen in LinearLayout

its a simple linear layout with 1 ImageView and 6 TextViews and a ScrollView but TextViews are appearing at the end of the screen and not below ImageView. I have tried editing my dp values in styles.xml but still not working please have a look!!
I have also tried editing my ImageView tags but still not working and don't know why TextViews are appearing at the end of the screen and if I remove ScrollView the texts are not visible.
Layout code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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">
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#000000"
tools:context="com.example.stan.sportbusinesscard.MainActivity">
<ImageView
android:scaleType="fitStart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="#string/photo_description"
android:src="#drawable/photo"
android:id="#+id/image"/>
<TextView
style="#style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title" />
<TextView
style="#style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text1"/>
<TextView
style="#style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/where" />
<TextView
style="#style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/address"
android:autoLink="map"/>
<TextView
style="#style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/when" />
<TextView
style="#style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/dateOf" />
</LinearLayout>
</ScrollView>
Styles.xml:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="LightText" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="android:paddingLeft">18dp</item>
<item name="android:paddingRight">18dp</item>
<item name="android:textColor">#aaaaaa</item>
</style>
<style name="TitleText" parent="AppTheme">
<!-- Customize your theme here. -->
<item name="android:paddingLeft">18dp</item>
<item name="android:paddingRight">18dp</item>
<item name="android:paddingTop">20dp</item>
<item name="android:textSize">18sp</item>
<item name="android:textColor">#FFD700</item>
</style>
</resources>
You ImageView hight is wrap_content this the reason why your textview are at the bottom of your screen
Try this set static height to your ImageView
<ImageView
android:scaleType="fitStart"
android:adjustViewBounds="true"
android:layout_width="match_parent"
android:layout_height="150dp"
android:contentDescription="#string/photo_description"
android:src="#drawable/photo"
android:id="#+id/image"/>
Try this!
In your <ImageView> scaleType is android:scaleType="fitStart" change it to android:scaleType="fitXY"
Don't use Scrollview as parent view and add android:adjustViewBounds="true" to Imageview for fit.
<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">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#000000"
>
<ImageView
android:scaleType="fitStart"
android:layout_width="match_parent"
android:adjustViewBounds="true"
android:layout_height="wrap_content"
android:contentDescription="#string/photo_description"
android:src="#drawable/photo"
android:id="#+id/image"/>
<TextView
style="#style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title" />
<TextView
style="#style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text1"/>
<TextView
style="#style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/where" />
<TextView
style="#style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/address"
android:autoLink="map"/>
<TextView
style="#style/TitleText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/when" />
<TextView
style="#style/LightText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/dateOf" />
</LinearLayout>
</ScrollView>
</LinearLayout>

Android: Changing color of the back button in tool bar

I am trying to make the back button on the toolbar black, but I can't find a way. For some reason I don't have toolBar in my xml file, so there is no way to change the color for me. Please let me know if there is another way.
I have the primaryColor white, but the back button is also white.
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/colorPrimaryDark</item>
<item name="colorAccent">#color/colorAccent</item>
<item name="colorControlNormal">#color/colorPrimaryDark</item>
<item name="actionMenuTextColor">#color/colorPrimaryDark</item>
</style>
This is my xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<Space
android:layout_width="match_parent"
android:layout_height="40dp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/taskNameEditText"
android:textAlignment="center"
android:hint="enter task name"/>
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:id="#+id/scrollLinearLayout">
</LinearLayout>
</HorizontalScrollView>
<Space
android:layout_width="match_parent"
android:layout_height="40dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/fromTimeEditText"
android:layout_weight="1"
android:hint="fromTime"
android:textAlignment="center" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:ems="10"
android:id="#+id/toTimeEditText"
android:layout_weight="1"
android:hint="toTime"
android:textAlignment="center" />
</LinearLayout>
</LinearLayout>
if you are using toolbar then you can change
toolbar.getNavigationIcon().setColorFilter(getResources().getColor(R.color.blue_gray_15), PorterDuff.Mode.SRC_ATOP);

Second Button in android is invisible

In the activity_main.xml is used
- ScrollView
- LinearLayout
- RelativeLayout
For TextView, RadioGroups, RadioButtons, EditText and Buttons.
App was running normal till resetButton added. After this app runs but resetButton is invisible.
I think there is a mistake between layouts maybe I should use another combination of layouts, I don't know.
Thanks for any help!
**activity_layout.xml**
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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="com.allyouask.hungryforhistory.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent">
<TextView
android:id="#+id/welcomeMessage"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
style="#style/welcomeMessage"
android:fontFamily="sans-serif-light"
android:text="Welcome to Hungry For History!\n Let's get started!"
android:layout_centerHorizontal="true"/>
<TextView
android:id="#+id/inputQuestion"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
style="#style/QuestionsStyle"
android:text=" Who was the king of the Gods in Ancient Greece:"
android:layout_below="#+id/welcomeMessage"/>
<EditText
android:id="#+id/inputAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/inputQuestion"/>
<TextView
android:id="#+id/firstQuestion"
style="#style/QuestionsStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/inputAnswer"
android:paddingLeft="5dp"
android:text="Who was born in Ancient City Stagira, Greece?"/>
<RadioGroup
android:id="#+id/firstGroupRadioButtons"
android:layout_below="#+id/firstQuestion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"/>
<RadioButton
android:id="#+id/firstLeftRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/firstGroupRadioButtons"
android:text="Aristotle"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/firstRightRadioButton"
android:layout_below="#+id/firstGroupRadioButtons"
style="#style/RadioButtonStyle"
android:layout_toRightOf="#+id/firstLeftRadioButton"
android:text="Pythagoras"
android:onClick="onRadioButtonClicked"/>
<TextView
android:id="#+id/secondQuestion"
style="#style/QuestionsStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/firstLeftRadioButton"
android:paddingLeft="5dp"
android:text="Who said in his last speech:With malice toward none;...let us strive on to finish the work we are in;to bind up the nation's wounds;into care for him who shall have borne the battle and for his widow and his orphans?"/>
<RadioGroup
android:id="#+id/secondGroupRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/secondQuestion"
android:orientation="horizontal"/>
<RadioButton
android:id="#+id/secondLeftRadioButton"
style="#style/RadioButtonStyle"
android:layout_alignParentLeft="true"
android:layout_below="#+id/secondGroupRadioButtons"
android:text="William McKinley"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/secondRightRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/secondGroupRadioButtons"
android:layout_toRightOf="#+id/secondLeftRadioButton"
android:text="Abraham Lincoln"
android:onClick="onRadioButtonClicked"/>
<TextView
android:id="#+id/thirdQuestion"
style="#style/QuestionsStyle"
android:layout_below="#+id/secondLeftRadioButton"
android:paddingLeft="5dp"
android:text="Where the An Lushan Rebellion took place?"/>
<RadioGroup
android:id="#+id/thirdGroupRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/thirdQuestion"
android:orientation="horizontal"/>
<RadioButton
android:id="#+id/thirdLeftRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/thirdGroupRadioButtons"
android:text="China"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/thirdRightRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/thirdGroupRadioButtons"
android:layout_toRightOf="#+id/thirdLeftRadioButton"
android:text="Thailand"
android:onClick="onRadioButtonClicked"/>
<TextView
android:id="#+id/fourthQuestion"
style="#style/QuestionsStyle"
android:layout_below="#+id/thirdLeftRadioButton"
android:text="Who was the most famous exemplar of absolute monarchy in France?"/>
<RadioGroup
android:id="#+id/fourthGroupRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/fourthQuestion"
android:orientation="horizontal"/>
<RadioButton
android:id="#+id/fourthLeftRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/fourthGroupRadioButtons"
android:text="Louis XIV"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/fourthRightCheckBox"
style="#style/RadioButtonStyle"
android:layout_below="#+id/fourthGroupRadioButtons"
android:layout_toRightOf="#+id/fourthLeftRadioButton"
android:text="Michael I"
android:onClick="onRadioButtonClicked"/>
<TextView
android:id="#+id/fifthQuestion"
style="#style/QuestionsStyle"
android:layout_below="#+id/fourthLeftRadioButton"
android:text="When Alexander The Great lived?"/>
<RadioGroup
android:id="#+id/fifthGroupRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/fifthQuestion"
android:orientation="horizontal"/>
<RadioButton
android:id="#+id/fifthLeftRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/fifthGroupRadioButtons"
android:text="330-323 BC"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/fifthRightRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/fifthGroupRadioButtons"
android:layout_toRightOf="#+id/fifthLeftRadioButton"
android:text="336-323 BC"
android:onClick="onRadioButtonClicked"/>
<TextView
android:id="#+id/sixthQuestion"
style="#style/QuestionsStyle"
android:layout_below="#+id/fifthLeftRadioButton"
android:text="Where Albert Einstein studied?"/>
<RadioGroup
android:id="#+id/sixthGroupRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/sixthQuestion"
android:orientation="horizontal"/>
<RadioButton
android:id="#+id/sixthLeftRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/sixthGroupRadioButtons"
android:text="University of Zurich"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/sixthRightRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/sixthGroupRadioButtons"
android:layout_toRightOf="#+id/sixthLeftRadioButton"
android:text="University of Germany"
android:onClick="onRadioButtonClicked"/>
<TextView
android:id="#+id/seventhQuestion"
style="#style/QuestionsStyle"
android:layout_below="#+id/sixthLeftRadioButton"
android:text="What was the main interest of Democritus?"/>
<RadioGroup
android:id="#+id/seventhGroupRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/seventhQuestion"
android:orientation="horizontal">
<RadioButton
android:id="#+id/seventhLeftRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/seventhGroupRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Mathematics-Astronomy"
android:onClick="onRadioButtonClicked"/>
<RadioButton
android:id="#+id/seventhRightRadioButton"
style="#style/RadioButtonStyle"
android:layout_below="#+id/seventhGroupRadioButtons"
android:layout_toRightOf="#+id/seventhLeftRadioButtons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Philosophy-Psychology"
android:onClick="onRadioButtonClicked"/>
</RadioGroup>
<Button
android:id="#+id/submitButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/backgroundColor"
android:layout_marginBottom="4dp"
android:text="Submit"
android:textColor="#color/textColor"
android:onClick="OnClick"
android:layout_alignParentBottom="true"/>
<Button
android:id="#+id/resetButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="3dp"
android:onClick="OnClick"
android:background="#color/backgroundResetColor"
android:textColor="#color/textColor"
android:text="Reset"
android:textAllCaps="true"
android:layout_below="#+id/submitButton"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
styles.xml
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#FFC107</item>
<item name="colorPrimaryDark">#E65100</item>
<item name="colorAccent">#EF6C00</item>
</style>
<style name="welcomeMessage">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_centerHorizontal">true</item>
<item name="android:paddingTop">10dp</item>
<item name="android:paddingBottom">10dp</item>
<item name="android:textSize">16sp</item>
<item name="android:textStyle">normal</item>
<item name="android:textColor">#EF6C00</item>
</style>
<style name="QuestionsStyle">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:paddingLeft">6dp</item>
<item name="android:paddingRight">6dp</item>
<item name="android:textSize">15sp</item>
<item name="android:textStyle">italic</item>
<item name="android:textColor">#000000</item>
</style>
<style name="RadioButtonStyle">
<item name="android:textSize">14sp</item>
<item name="android:textColor">#FFAB00</item>
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textStyle">bold</item>
<item name="android:paddingLeft">6dp</item>
</style>
colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="colorPrimary">#FFC107</color>
<color name="colorPrimaryDark">#E65100</color>
<color name="colorAccent">#EF6C00</color>
<!-- Button Colors -->
<color name="backgroundColor">#EF6C00</color>
<color name="backgroundResetColor">#FB8C00</color>
<color name="textColor">#FFFFFF</color>
</resources>
</resources>
Using your code I get this Output. Are you want this or something else.
I have put your code inside this
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
// your code here..
</RelativeLayout>
</ScrollView>
'
UpDate :
you have to give id this way.. and check layout_below property to both Button.
<Button
android:id="#+id/submitButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/seventhGroupRadioButtons"
android:layout_marginBottom="4dp"
android:layout_marginTop="10dp"
android:background="#android:color/black"
android:onClick="OnClick"
android:text="Submit"
android:textColor="#android:color/white" />
<Button
android:id="#+id/resetButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/submitButton"
android:layout_marginBottom="3dp"
android:layout_marginTop="2dp"
android:onClick="OnClick"
android:text="Reset"
android:textAllCaps="true"
android:textColor="#android:color/black" />

how to change highlight color on editText field

Below is a screen shot of a custom edit text field i have in my android app. While you are type a given word, the text for the word you are currently typing highlights in grey and shows the text as black, until you hit the space bar at which time the text turns white as expected. Is there a way to change the color of the highlight and the text that is highlighted?
my edit text xml looks like this
<EditText
android:id="#+id/searchField"
android:layout_width="160dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:background="#null"
android:cursorVisible="true"
android:ems="10"
android:textColor="#color/white"
android:textColorHighlight ="#ff0000"
android:textCursorDrawable="#null" >
</EditText>
the whole layout
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!--
As the main content view, the view below consumes the entire
space available using match_parent in both dimensions.
-->
<RelativeLayout
android:id="#+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff" >
<fragment
android:id="#+id/map"
android:name="com.sapientnitro.inhouse.drop.components.DRPCustomMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<ImageButton
android:id="#+id/btn_center_local"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="50dp"
android:layout_marginRight="15dp"
android:background="#drawable/btn_center_on_local_up" />
<RelativeLayout
android:id="#+id/top_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#ddffffff" >
<ImageButton
android:id="#+id/btn_menu"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginRight="12dp"
android:layout_toLeftOf="#+id/btn_search"
android:background="#drawable/btn_menu_up" />
<ImageButton
android:id="#+id/btn_create"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_marginBottom="10dp"
android:layout_marginLeft="12dp"
android:layout_toRightOf="#+id/btn_search"
android:background="#drawable/btn_create_up" />
<ImageButton
android:id="#+id/btn_search"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:background="#drawable/btn_search_up" />
</RelativeLayout>
<LinearLayout
android:id="#+id/search"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ddffffff"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/search_bar"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#dd00cccb" >
<ImageView
android:id="#+id/searchBox"
android:layout_width="238dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:src="#drawable/search_field" />
<ImageView
android:id="#+id/clear"
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="220dp"
android:src="#drawable/btn_clear_field" />
<EditText
android:id="#+id/searchField"
android:layout_width="160dp"
android:layout_height="44dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="60dp"
android:background="#null"
android:cursorVisible="true"
android:ems="10"
android:textColor="#color/white"
android:textColorHighlight ="#color/white"
android:textCursorDrawable="#null" >
</EditText>
<TextView
android:id="#+id/cancelBTN"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="16dp"
android:textColor="#color/white"
android:textSize="22dp"
android:text="#string/cancel" />
</RelativeLayout>
<ScrollView
android:id="#+id/search_results_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
android:paddingTop="2dp"
android:scrollbars="none" >
<LinearLayout
android:id="#+id/search_results_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<RelativeLayout
android:id="#+id/header_artists"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="#+id/results_artists"
android:layout_width="match_parent"
android:layout_height="150dp" />
<RelativeLayout
android:id="#+id/header_followers"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="#+id/results_followers"
android:layout_width="match_parent"
android:layout_height="150dp" />
<RelativeLayout
android:id="#+id/header_places"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#dd00cccb" />
<HorizontalScrollView
android:id="#+id/results_places"
android:layout_width="match_parent"
android:layout_height="150dp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
<ListView
android:id="#+id/left_drawer"
android:layout_width="255dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#dd00cccb"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="#drawable/selector_transparent" />
<ListView
android:id="#+id/right_drawer"
android:layout_width="255dp"
android:layout_height="match_parent"
android:layout_gravity="end"
android:background="#dd00cccb"
android:choiceMode="singleChoice"
android:divider="#android:color/transparent"
android:dividerHeight="0dp"
android:listSelector="#drawable/selector_transparent" />
</android.support.v4.widget.DrawerLayout>
I was able to change the highlight of my edit text by adding this line to my themes.xml file:
<item name="android:textColorHighlight">#color/m_highlight_blue</item>
Simple, just use TextHightLight Property in XML Mode
android:textColorHighlight="#ff0000"
or add this in your theme
<item name="android:textColorHighlight">"#ff0000"</item>
[Image attached here is because for a comment below]
and when i do, this is how it looks
And if you have to change the Marker handle then you should change
<item name="colorAccent">#color/edittext_handle_selection</item>
<item name="android:textColorHighlight">#color/edittext_selection</item>
In code:
et.setHighlightColor(ContextCompat.getColor(getContext(), R.color.highlight));
You should use android:textColorHighlight in the EditText element in you layout xml file
In material design you will get the default ascent color in style so the all text selection and other theme would be according to that color. You can change this ascent color in following way -
Go to the style.xml and change the following color -
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorAccent">#color/colorAccent</item> // Replace this color with your own choice
</style>
you should use a selector to change text colors`:
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Pressed State -->
<item android:state_pressed="true"
android:color="#FF0000" />
<!-- Focused State -->
<item android:state_focused="true"
android:color="#FF0000" />
<!-- Default State -->
<item android:color="#FFFFFF" />
And then set your textColor property to #drawable/selector_name
use this code,might be its help you
android:textColorHighlight="your color code"
well there's a simpler way to do it...I was here to look for an answer, but im answering my own answer.
If you go to the attractions place go all the way down to the letter T and there should be an TextColorHighlight but if you don't see it the there should be ones
that aren't fully shown so go hover over them and then the full word will show
the showed be little color icons beside them you should press them and select your color. And then go to your code and enter TextColorHighlight Press Tab and then enter the name of the color, then run it!
Hope that this worked out for you, sorry I couldn't add any pictures of how'd it would of looked. Oh and maybe you're wondering why didn't it automatically do that then have me do it? Now im wondering that too, ill try to see what i can do

Categories