android標題欄圖片
『壹』 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,但這樣有點大才小用了,所以不建議使用。