当前位置:首页 » 安卓系统 » android标题栏图片

android标题栏图片

发布时间: 2022-06-19 17:48:44

‘壹’ xamarin android 怎么在标题栏左侧添加图片

设置里用搜索搜索一下

‘贰’ 如何设置app顶部标题栏背景 android

设置Android的Activity标题的背景是有多种方法的

首先最简单的是直接在布局里面设置个background
其中background是可以直接使用颜色或者图片或者是自定义的形状
还有就是可以利用Android:theme 自带的主题背景设置
设置theme更改主题背景

下面是自带的theme说明文档
Android应用开发——系统自带样式Android:theme

•android:theme="@android:style/Theme.Dialog" 将一个Activity显示为能话框模式
•android:theme="@android:style/Theme.NoTitleBar" 不显示应用程序标题栏

‘叁’ android 中,给标题栏添加图片之后,两边仍然留有部分空隙,不知道这个一般是如何解决的,请各位大侠指教!

对图片进行拉伸呗。

‘肆’ android 选项卡的标题栏怎么更改成自己的图片如图灰色的部分怎么更改

用tab布局,自己定义tab标签内容

‘伍’ android怎么写个自己的标题栏

我们做应用的时候经常想有自己的标题栏,在android平台示例:
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_1);

custom_title_1为自己定义的标题栏风格的xml文件索引。

当然仅仅这样我们是去不掉系统的标题的,仅仅是在系统标题栏下面增加了一条自己的(客户,注:android
UI系统是C/S模式)标题,怎么用自己的标题栏覆盖系统的呢?下面我们设计自己风格的标题。

两种方式哦

1:

首先建立自己的styles.xml文件,如下:

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

<!-- Copyright (C) 2007 The Android Open Source Project

Licensed under the Apache License, Version 2.0 (the
"License");

you may not use this file except in compliance with the
License.

You may obtain a of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in
writing, software

distributed under the License is distributed on an "AS
IS" BASIS,

WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
express or implied.

See the License for the specific language governing
permissions and

limitations under the License.

-->

<resources>

<!-- Base application theme is the default theme.
-->

<style name="Theme" parent="android:Theme">

</style>

<!-- Variation on our application theme that forces a
plain

text style. -->

<style name="Theme.PlainText">

<item
name="android:textAppearance">@style/TextAppearance.Theme.PlainText</item>

</style>

<!-- Variation on our application theme that has a
black

background. -->

<style name="Theme.Black">

<item
name="android:windowBackground">@drawable/screen_background_black</item>

</style>

<!-- A theme for a custom dialog appearance.
Here we use an ugly

custom frame. -->

<style name="Theme.CustomDialog"
parent="android:style/Theme.Dialog">

<item
name="android:windowBackground">@drawable/filled_box</item>

</style>

<!-- A theme that has a wallpaper background.
Here we explicitly specify

that this theme is to inherit from the
system's wallpaper theme,

which sets up various attributes
correctly. -->

<style name="Theme.Wallpaper"
parent="android:style/Theme.Wallpaper">

<item
name="android:colorForeground">#fff</item>

</style>

<!-- A theme that has a translucent background.
Here we explicitly specify

that this theme is to inherit from the
system's translucent theme,

which sets up various attributes
correctly. -->

<style name="Theme.Translucent"
parent="android:style/Theme.Translucent">

<item
name="android:windowBackground">@drawable/translucent_background</item><!--
@drawable/translucent_background -->

<item
name="android:windowNoTitle">true</item>

<item
name="android:colorForeground">#fff</item>

</style>

<!-- Variation on our application theme that has a
transparent

background; this example completely
removes the background,

allowing the activity to decide how to
composite. Also here we

force the translucency ourself rather
than making use of the built-in

translucent theme. -->

<style name="Theme.Transparent">

<item
name="android:windowIsTranslucent">true</item><!-- true -->

<item
name="android:windowAnimationStyle">@android:style/Animation.Translucent</item>

<item
name="android:windowBackground">@drawable/transparent_background</item>

<item
name="android:windowNoTitle">true</item>

<item
name="android:colorForeground">#fff</item>

</style><style name="TextAppearance.Theme.PlainText"
parent="android:TextAppearance.Theme">

<item
name="android:textStyle">normal</item>

</style>

<style name="ImageView120dpi">

<item
name="android:src">@drawable/stylogo120dpi</item>

<item
name="android:layout_width">wrap_content</item>

<item
name="android:layout_height">wrap_content</item>

</style>

<style name="ImageView160dpi">

<item
name="android:src">@drawable/stylogo160dpi</item>

<item
name="android:layout_width">wrap_content</item>

<item
name="android:layout_height">wrap_content</item>

</style>

<style name="ImageView240dpi">

<item
name="android:src">@drawable/stylogo240dpi</item>

<item
name="android:layout_width">wrap_content</item>

<item
name="android:layout_height">wrap_content</item>

</style>

<style
name="WindowTitleBackground_my">

<item
name="android:background">@drawable/title_bar</item>

</style>

<style
name="theme_mybackground">

<item
name="android:windowFullscreen">true</item>

<item
name="android:windowTitleBackgroundStyle">@style/WindowTitleBackground_my</item>

</style>

</resources>

此文件是我从google给的示例代码里面拷贝出来的,红色是为去掉系统标题栏新添加的,我们定义了自己标题栏的背景图片(或者定义颜色也可),theme_mybackground
是覆盖了系统风格,系统默认的android:windowFullscreen为false,修改系统默认的windowTitleBackGroundStyle为自己的风格Drawable,OK,下面比较关键的来了,在你的应用程序的Activity的超类里面,在用super.onCreate(savedInstanceState);之前写一句代码如下:

setTheme(R.style.theme_mybackground);

super.onCreate(savedInstanceState);

//do something.

或者加入AndroidManifest.xml

OK,测试运行之

2:

直接在代码里面写

getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE,
R.layout.custom_title_1);

custom_title_1为我们自己的标题栏风格,

测试运行之

转载

‘陆’ android标题栏icon怎样渐变

在layout.xml文件中配置相关属性。
[html] view plain

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">

<com.david.gradientuilibrary.GradientIconView
android:id="@+id/apple_icon"
app:bottom_icon="@mipmap/apple_1998"
app:top_icon="@mipmap/apple_2007"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<com.david.gradientuilibrary.GradientTextView
android:id="@+id/apple_label"
app:bottom_text_color="@color/apple_black"
app:text="@string/apple_logo"
app:text_size="32sp"
app:top_text_color="@color/apple_gray"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

</LinearLayout>

<SeekBar
android:id="@+id/gradientui_seekbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"/>

</LinearLayout>
代码中实现
[java] view plain
package com.david.gradientuisample;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.SeekBar;

import com.david.gradientuilibrary.GradientIconView;
import com.david.gradientuilibrary.GradientTextView;

public class MainActivity extends AppCompatActivity {

private GradientIconView mAppleLogo;
private GradientTextView mAppleLabel;
private SeekBar mSeekbar;

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}

private void initView() {
mAppleLogo = (GradientIconView) findViewById(R.id.apple_icon);
mAppleLabel = (GradientTextView) findViewById(R.id.apple_label);
mSeekbar = (SeekBar) findViewById(R.id.gradientui_seekbar);
mSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mAppleLogo.setIconAlpha((progress * 1.0f) / 100);
mAppleLabel.setTextViewAlpha((progress * 1.0f) / 100);
}

@Override
public void onStartTrackingTouch(SeekBar seekBar) {

}

@Override
public void onStopTrackingTouch(SeekBar seekBar) {

}
});
}
}

‘柒’ android的MainActivity的自带标题栏中能否加入图片按钮呢,点击触发事件,必须要自定义一个标题栏吗

建议你取消系统TitleBar然后自己定义一个,目前大多数开发都是自己定义TitleBar,可以将TitleBar定义成一个控件,也方便后期的使用方便。而且系统默认的TitleBar是无法完成你需要的操作,除非你引入V7 jar包 Activity继承ActionBarActivity,但这样有点大才小用了,所以不建议使用。

热点内容
少女前线防检测脚本 发布:2025-05-16 08:59:07 浏览:728
编译器对系统的依赖 发布:2025-05-16 08:37:29 浏览:711
javamap数组 发布:2025-05-16 08:37:28 浏览:451
移动光猫如何自行修改密码 发布:2025-05-16 08:20:15 浏览:124
作为基线存储 发布:2025-05-16 08:15:22 浏览:858
安卓怎么关闭手机应用推荐 发布:2025-05-16 08:03:38 浏览:929
sql内置函数 发布:2025-05-16 08:03:34 浏览:923
怎么看服务器内存型号 发布:2025-05-16 08:03:30 浏览:813
哪里修安卓手机最好 发布:2025-05-16 07:58:25 浏览:825
服务器和电脑是什么区别 发布:2025-05-16 07:58:24 浏览:720