2016-10-06 3 views
2

Я хочу создать активность входа для своего приложения, но макет по умолчанию продолжает отображаться при запуске моего приложения в AVD.Как изменить макет по умолчанию (activity_main) в студии android

i don't want any blue on my layout, all i want in the yellow part

ниже мой файл макета

<?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:orientation="vertical" 
android:weightSum="1" 
android:paddingLeft="20dp" 
android:paddingTop="20dp" 
android:paddingRight="20dp" 
android:paddingBottom="20dp" 
android:background="@android:color/holo_orange_light"> 


<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:text="@string/mobile_money_market" 
    android:layout_weight="0.05" 
    android:textAlignment="center" 
    android:inputType="text" 
    android:textStyle="bold" /> 

<TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center_horizontal" 
    android:layout_weight="0.05" 
    android:text="@string/free_advertising" 
    android:textAlignment="center" /> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textEmailAddress" 
    android:ems="10" 
    android:id="@+id/editText1" 
    android:hint="Email..." 
    android:layout_marginTop="30dp" /> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="textPassword" 
    android:ems="10" 
    android:id="@+id/editText2" 
    android:hint="Password..." 
    android:layout_marginTop="20dp" /> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:orientation="horizontal" 
    android:id="@+id/item"> 

    <Button 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:text="@string/sign_in" 
     android:id="@+id/sign_in_button" 
     android:layout_weight="1" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/sign_up" 
     android:id="@+id/sign_up_button" 
     android:background="@color/errorColor" /> 

</LinearLayout> 
</LinearLayout> 

Я хочу знать, как извлечь синюю часть от моей деятельности. Я не хочу, чтобы название Mobile Money Market появилось дважды, как показано на картинке выше.

Я хочу удалить стандартный заголовок Android (часть в синем) из макета.

my layout as it appears on my AVD

мне нужна помощь, пожалуйста. Может кто-нибудь посоветует мне, что делать или что не делать. Заранее спасибо

ответ

0

Вам нужно, чтобы скрыть панель действий. Самый простой способ сделать это - добавить стиль в файл style.xml. Что-то вроде этого:

<resources> 
    <!-- No action bar theme --> 
    <style name="NoActionBar" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/blueDark</item> 
     <item name="colorPrimaryDark">@color/blueDark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
    </style> 
</resources> 

Вы заметили родителя? "NoActionBar". И тогда в вашем манифесте изменить тему вашей деятельности:

<activity 
     android:name="your.package.name.YourActivity" 
     android:label="@string/application_name" 
     android:theme="@style/NoActionBar" /> 
0
requestWindowFeature(Window.FEATURE_NO_TITLE); 
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, 
      WindowManager.LayoutParams.FLAG_FULLSCREEN); 

Добавьте эти строки перед setContentView

+0

этот код не работает –

0

Вы можете попробовать этот код ..

Mainactivity.java

public class MainActivity extends AppCompatActivity { 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.activity_main); 

    } 
}   

main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="@android:color/holo_orange_light"  
android:orientation="vertical"> 

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="50dp" 
    android:background="@android:color/holo_orange_light"> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center" 
     android:text="Home Activity" 
     android:textSize="20sp" /> 
</LinearLayout> 

и style.xml

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 
0

Вы можете получить доступ к этому СИНИЙ бар согласно вашему требованию от «Стили» файла ресурсов. Вы можете изменить цвет, тему, стиль и т. Д. По мере необходимости. Перейти к файлам XML, нажмите: -

res -> values ​​-> styles.

Смежные вопросы