In the activity_main.xml is used
- ScrollView
- LinearLayout
- RelativeLayout
Для TextView
, RadioGroups
, RadioButtons
, EditText
и Button
с. Приложение функционировало нормально до resetButton
добавлен. После этого приложения работает, но resetButton
невидимо. Я думаю, что есть ошибка между макетами, может быть, я должен использовать другую комбинацию макетов, я не знаю. Спасибо за любую помощь!Вторая кнопка в андроиде невидима
**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>
Этот результат мне нужно Но в моем телефоне я не могу видеть кнопку сброса – elZ
я не знаю, если проблема в том, что у меня было предупреждение сегодня и вчера <андроид из памяти> Я не могу представить себе что-то еще – elZ
@ElenJ см. Мой ответ. – Ironman