`

android > layout > background 背景图片重复

 
阅读更多
contrl_index_top_bar_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/contrl_top_bar_bg"
    android:tileMode="repeat" />
 
调用
  	    <RelativeLayout 
	        android:layout_width="fill_parent"
	        android:layout_height="fill_parent"
	        android:layout_weight="9" 
	        android:background="@drawable/contrl_index_top_bar_bg"
	        > 
		   
	    </RelativeLayout> 
 

实际上在 android 中, 即便 直接  android:background = "@drawable/contrl_top_bar_bg"   也可以达到效果,
区别是,   直接 加载图片 为背景会将 图片 以一定比例 显示完整即会被拉伸,   加载 style 的话则 以原有布局的大小不变,图片 大小不变 镶嵌其中,会出现repeat效果类似 HTML 里面的 CSS 背景图片  









 


 





 







 

  • 大小: 268 Bytes
  • 大小: 212 Bytes
  • 大小: 2.8 KB
分享到:
评论

相关推荐

    android 界面 渐变背景颜色

    渐变背景主要通过`&lt;gradient&gt;`标签在XML资源文件中定义,该标签位于`&lt;shape&gt;`标签内部,属于Android图形资源的一部分。`&lt;gradient&gt;`支持多种属性设置,如开始颜色(`android:startColor`)、结束颜色(`android:...

    Android UI设计技巧

    android:background="@drawable/gradient_background"&gt; &lt;!-- 布局元素 --&gt; &lt;/LinearLayout&gt; ``` #### 三、灵活使用`styles.xml` 通过使用`styles.xml`文件,可以更好地管理应用程序的主题和样式,提高代码的可...

    Android Style实例总结

    &lt;item name="android:background"&gt;@drawable/btn_border&lt;/item&gt; &lt;/style&gt; &lt;!-- 布局文件 --&gt; android:id="@+id/button_bordered" android:layout_width="wrap_content" android:layout_height="wrap_content" ...

    Android中使用LinearLayout完成的四书五经首界面的代码清单 .pdf

    `android:background="@drawable/sswj"`用于设置背景图片,而`android:gravity="right|bottom"`则表示所有子视图将被放置在布局的右下角。 在LinearLayout内部,我们通常会包含多个子视图,如TextView、ImageView等...

    android仿ios应用图片数字显示(支持部分手机)

    android:background="@drawable/badge_background" /&gt; &lt;/merge&gt; ``` 接下来,我们需要处理动态更新数字的部分。这通常涉及到监听消息或者通知的数量,并在数量改变时更新TextView的文本。在Java或Kotlin代码中,...

    Android 带图片的按钮源码.zip

    在布局文件中,可以使用`&lt;android.widget.Button&gt;`或`&lt;com.example.CustomButton&gt;`(如果自定义了类)标签来创建一个按钮,并通过`android:background`属性设置背景图片。例如: ```xml android:id="@+id/...

    android_自定义TitleBar

    android:background="@android:color/white" /&gt; android:id="@+id/ll_operation" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" android:...

    Android强制控件圆角实现

    然而,这种方法在多分辨率和动态尺寸的Android环境中并不理想,因为我们需要为不同尺寸的设备准备多个背景图片。 另一种常见方法是使用Shape Drawable,这是一种XML资源,允许我们定义形状(如矩形、椭圆等)并为其...

    Android样式使用

    android:background="@drawable/bottom_bar"&gt; android:id="@+id/bottombae" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal"&gt; android:id="@...

    Android 序列帧动画,开始,结束监听的解决Demo.zip

    android:background="@drawable/frame_animation" /&gt; ``` 5. **注意事项** - 确保所有的帧图片尺寸相同,以避免在播放动画时出现缩放或拉伸的问题。 - `duration`属性的值决定了动画的流畅度,数值越小,动画...

    android UI设计

    android:background="@drawable/gradient_bg"&gt; &lt;!-- 其他布局元素 --&gt; &lt;/LinearLayout&gt; ``` #### 3. 灵活使用`styles.xml` 在Android应用开发中,`styles.xml`文件用于定义整个应用程序或某个特定组件的样式,...

    android绚丽动画大全

    android:background="@drawable/frame_animation" /&gt; ``` 4. **启动和控制动画**:在Activity或Fragment的代码中,获取到`AnimationDrawable`对象,并调用`start()`方法开始动画。要停止动画,可以调用`stop()`...

    android 逐帧动画实现 源码

    android:background="@anim/frame_animation" /&gt; ``` 4. **启动和控制动画**:在Activity或Fragment的代码中,获取`AnimationDrawable`对象并启动或停止动画。 ```java ImageView imageView = findViewById(R....

    Android UI中的style和theme以及AlertDialog

    &lt;item name="android:background"&gt;@drawable/button_shape&lt;/item&gt; &lt;item name="android:textSize"&gt;18sp&lt;/item&gt; &lt;/style&gt; &lt;!-- layout.xml --&gt; android:layout_width="wrap_content" android:layout_height=...

    android颜色设置实例

    1. **XML布局文件**:在XML布局文件中,可以通过`android:background`属性直接设置元素的背景颜色。例如,对于一个LinearLayout,可以这样写: ```xml xmlns:android=...

    Android简单2D动画源码.zip

    android:background="@drawable/animation_list" /&gt; ``` 最后,在Activity的`onCreate()`方法中: ```java ImageView imageView = findViewById(R.id.animation_view); AnimationDrawable frameAnimation = ...

    Android基本框架的搭建

    需要调整该布局,去除内边距(`android:padding="0dp"`),并将背景色设为白色(`android:background="@android:color/white"`或`android:background="#FFFFFF"`,取决于使用的API版本)。 3. **添加ImageView**: - 向...

    Android布局优化

    android:background="@color/titlebar_bg"&gt; android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/gafricalogo"/&gt; &lt;/FrameLayout&gt; ``` #### 三、动态加载视图 ...

    安卓点9图片操作指南

    在Android开发中,9.png(也称为9-patch或九宫格图片)是一种特殊格式的图像,用于创建可自适应内容大小的UI元素,如按钮、背景等。它允许开发者指定图片的哪些部分应该拉伸,哪些部分应保持不变,以确保在不同尺寸...

Global site tag (gtag.js) - Google Analytics