相关疑难解决方法(0)

android通知栏和标题栏的大小?

有没有办法获得android中通知栏和标题栏的大小?目前我获得了显示宽度和高度:

Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height = display.getHeight();
Run Code Online (Sandbox Code Playgroud)

之后,我想减去条形的大小,这样我就可以在不丢失宽高比的情况下拉伸视频.目前我隐藏了酒吧,因为我看不到更好的方式.

android

24
推荐指数
3
解决办法
5万
查看次数

在Android中创建自定义标题栏

我为我的应用程序创建了一个自定义标题栏,但我在实现它时遇到了一些问题.我想更改文本和标题栏的颜色和外观

styles.xml的布局如下:

<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="MyTheme">
    <item name="android:tabWidgetStyle">@style/LightTabWidget</item>


</style>
<style name="MyWindowTitleBackground" parent="@android:style/WindowTitleBackground">
    <item name="android:background">@android:drawable/title_bar</item>

</style>

<style name="MyWindowTitle" parent="@android:style/WindowTitle">
    <item name="android:singleLine">true</item>
    <item name="android:windowTitleSize">40dip</item>
    <item name="android:textAppearance">@style/MyTextAppearance</item>
    <item name="android:shadowColor">#BB000000</item>
    <item name="android:shadowRadius">2.75</item>
</style>
 <style name="MyTextAppearance" parent="@android:style/TextAppearance.WindowTitle">
    <item name="android:textColor">#3A6629</item>
    <item name="android:textSize">14sp</item>
    <item name="android:textStyle">bold</item>
</style>

<style name="LightTabWidget" parent="@android:style/Widget.TabWidget">

    <item name="android:textSize">20px</item>
    <item name="android:textStyle">bold</item>

    <item name="android:textColor">#FF5721</item>
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)

我在清单文件中添加了以下主题:

 <application android:icon="@drawable/icon" android:label="@string/app_name" android:theme="@android:style/Theme.Light">
   <activity android:name="LAFoodBankAboutUs" android:label="@string/app_name" android:theme="@style/MyTheme">
Run Code Online (Sandbox Code Playgroud)

我需要做些什么才能显示自定义标题栏?

android android-widget android-emulator android-layout

11
推荐指数
1
解决办法
4万
查看次数

如何将菜单和设置选项添加到Android的自定义标题栏?

我的要求是增加标题栏的高度,但我不确定这是否可行.如果是我怎么能增加它的高度所以我会有更多的空间.如果不是,我需要在我的自定义标题栏中添加一个菜单选项(汉堡风格).

custom_title_bar.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/title_bar"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#77b48e"
    android:gravity="center_vertical"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent" >

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="29dp"
            android:layout_height="28dp"
            android:maxWidth="1dp"
            android:src="@drawable/logo" />

        <TextView
            android:id="@+id/title_bar_viewname"
            android:layout_width="wrap_content"
            android:layout_height="16dp"
            android:layout_weight="0.07"
            android:text="@string/app_name"
            android:textColor="@android:color/white"
            android:textSize="10sp" />

    </LinearLayout>

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >
    </LinearLayout>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

MainActivity.java

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_main);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.custom_title_bar);
    }
Run Code Online (Sandbox Code Playgroud)

android

9
推荐指数
1
解决办法
2万
查看次数