当前位置:首页 » 安卓系统 » android设置壁纸代码

android设置壁纸代码

发布时间: 2022-10-06 03:20:27

安卓手机怎么设置壁纸

若使用的是vivo手机,可参考以下设置壁纸的方式:
一、设置自动更换节日壁纸
1、进入设置--锁屏、桌面与壁纸--锁屏设置--打开节日锁屏壁纸开关;
2、进入i主题→我的→设置→开启“节日锁屏壁纸”。
二、设置锁屏壁纸的方法
进入手机i主题--我的--锁屏--选择喜欢的图片设置为壁纸;也可以在i主题--精选--壁纸里下载喜欢的壁纸。
三、设置桌面壁纸的方法
进入i主题--我的--壁纸中设定,或点击右上角的相册,将喜欢的照片设置为壁纸;也可以在i主题--精选--壁纸中下载。
四、设置动态壁纸的方法
可以进入手机i主题--我的--壁纸,设置动态壁纸。其它情况下手机本身不支持将动态图片和视频设置成桌面壁纸和锁屏。
也可以尝试使用第三方软件实现。
备注:抖音的参考设置方法:抖音界面--登录抖音账号--找到视频--点击右下角的“分享”按钮--左滑找到“动态壁纸”--设置即可。
手机的锁屏样式不能为阅图,否则动态图片和视频不能替换到锁屏。
五、设置壁纸跟随屏幕滚动
1、打开 i主题——壁纸——选择一个喜欢的横向壁纸
2、下载并应用壁纸后,选择“修剪壁纸”
3、选择横向应用壁纸,确定以后,返回桌面,就可以看到桌面壁纸随屏滚动了 。
注意事项:需壁纸宽度大于长度
2. 设置壁纸时需选择横向
3. 进入i主题--右上角图标--设置--关闭循环滑屏功能
六、将喜欢的图片设置为锁屏壁纸
进入相册--点击喜欢的图片--更多--设为壁纸--锁屏壁纸--确定。

② Android系统如何设置手机壁纸

如您需要设置Android系统的手机壁纸请先手指长触屏幕,会弹出“添加到主页屏幕”窗口,点击其中的“壁纸”。在出现的下拉窗口中,“壁纸图片”是内置的一些壁纸,“图片”里你以设置SD卡里的图片或者已拍摄的照片做为壁纸。(上述内容仅适用于广东联通用户)

③ android中代码是如何实现调用动态壁纸的

调用后动态壁纸其实是显示在Activity的后面,而Activity则是透明显示,这样就可以看到下面的动态壁纸,如果Activity不是透明的则什么也看不到。
代码中有用到两个接口
IWallpaperService mService;
IWallpaperEngine mEngine;
我们可以看到该目录下面有三个aidl接口,分别是
interface IWallpaperConnection {
void attachEngine(IWallpaperEngine engine);
ParcelFileDescriptor setWallpaper(String name);
}
oneway interface IWallpaperService {
void attach(IWallpaperConnection connection,
IBinder windowToken, int windowType, boolean isPreview,
int reqWidth, int reqHeight);
}

oneway interface IWallpaperEngine {
void setDesiredSize(int width, int height);
void setVisibility(boolean visible);
void dispatchPointer(in MotionEvent event);
void dispatchWallpaperCommand(String action, int x, int y, int z, in Bundle extras);
void destroy();
}
定义壁纸管理和壁纸信息变量

private WallpaperManager mWallpaperManager = null;
private WallpaperInfo mWallpaperInfo = null;
private WallpaperConnection mWallpaperConnection = null;
private Intent mWallpaperIntent;
初始化这些变量

mWallpaperManager = WallpaperManager.getInstance(this);
mWallpaperInfo = mWallpaperManager.getWallpaperInfo();//如果返回null则说明当前不是动态壁纸
mWallpaperIntent = new Intent(WallpaperService.SERVICE_INTERFACE);
mWallpaperIntent.setClassName(mWallpaperInfo.getPackageName(), mWallpaperInfo.getServiceName());
绑定动态壁纸服务

bindService(mIntent, this, Context.BIND_AUTO_CREATE);
IWallpaperService mService;//这里有一个adil接口

在连接监听中试着attach

public void onServiceConnected(ComponentName name, IBinder service) {
mService = IWallpaperService.Stub.asInterface(service);
try {
mService.attach(this, view.getWindowToken(),
// WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA_OVERLAY,
WindowManager.LayoutParams.TYPE_APPLICATION_MEDIA,
true, root.getWidth(), root.getHeight());
} catch (RemoteException e) {
Log.w("", "Failed attaching wallpaper; clearing", e);
}
}

④ Android自定义动态壁纸开发

看到有些手机酷炫的动态壁纸,有没有好奇过他们是如何实现的,其实我们自己也可以实现。

如果你了解使用过SurfaceView的话,那么开发一款动态壁纸对你来说其实非常简单。

动态壁纸的本质其实就是一个服务在维护一个动态壁纸引擎Engine,所以我们看到的动态效果其实是通过这个引擎画出来的。而维护这个引擎的服务,就是WallpaperService。本篇文章并不讨论内部实现原理,只是让大家知道如何去实现动态壁纸,所以就不详细说了。

大体上可分为三个步骤:

创建自定义WallpaperService继承WallpaperService
在Manifest中注册该Service并添加相关属性
创建所需要的xml文件
1.创建自定义WallpaperService

2.Manifest注册

一定要添加的几个地方:permission、intent-filter、meta-data。

3.创建需要的xml文件

这个xml文件就是Manifest中meta-data中的resource需要的文件:

需要注意第二个属性:settingsActivity,这个属性可以设置也可以不设置,他是启动一个设置动态壁纸的界面,一般情况下其实用不到这个界面,我们一般会使用PreferenceActivity去实现。下面是添加该属性和不添加该属性的区别:

完成这些之后,就是我们设计动态壁纸的时候了。回到自定义的Wallpaper类中:

我们当时在类中自定义了一个内部类MyEngine继承自Engine。这个Engine就是用来绘制的。关于Engine的几个主要方法如下:

onOffsetsChanged要注意一下,还记得有的手机滑动桌面时候背景图片会跟着左右移动吗,这个方法就可以实现这个效果,在手势滑动的每一帧都会回调依次。一下是个人理解的参数的含义:

xOffset:x方向滑动的百分比(与桌面分页数有关)

yOffset:y方向滑动百分比(一般用不到)

xOffsetStep:x方向每个分页所占的百分比(1 / xOffsetStep = 桌面的分页数)

yOffsetStep:同

xPixelOffset:x放下像素偏移量

y。。。。。
4.绘制。

实现绘制的方式,就跟SurfaceView的绘制一样了:

我只是简单的话了一个红色背景,效果如下:

当然可以实现很多不同的效果,这个就根据不同的需求去实现了。

⑤ Android开发设置锁屏壁纸

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
File file = new File("mnt/sdcard2/DCIM/Camera/IMG_20120216_160054.jpg");
Intent intent = createSetAsIntent(Uri.fromFile(file),null);
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
startActivity(Intent.createChooser(intent, "设置壁纸"));
// file:///mnt/sdcard2/DCIM/Camera/IMG_20120216_160054.jpg
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}

public static Intent createSetAsIntent(Uri uri, String mimeType) {
// Infer MIME type if missing for file URLs.
if (uri.getScheme().equals("file")) {
String path = uri.getPath();
int lastDotIndex = path.lastIndexOf('.');
if (lastDotIndex != -1) {
mimeType = MimeTypeMap.getSingleton()
.getMimeTypeFromExtension(
uri.getPath().substring(lastDotIndex + 1)
.toLowerCase());
}
}

Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
intent.setDataAndType(uri, mimeType);
intent.putExtra("mimeType", mimeType);
return intent;
}

⑥ android开发之设置桌面壁纸

/**
* 裁剪图片方法实现
* @param uri = Uri.fromFile(new File(path));
*/
public void startPhotoZoom(Uri uri ,Context context) {

Intent intent = new Intent("com.android.camera.action.CROP");
intent.setDataAndType(uri, "image/*");
//下面这个crop=true是设置在开启的Intent中设置显示的VIEW可裁剪
intent.putExtra("crop", "true");
// aspectX aspectY 是宽高的比例
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
// outputX outputY 是裁剪图片宽高
intent.putExtra("outputX", 150);
intent.putExtra("outputY", 150);
intent.putExtra("return-data", true);
((Activity)context).startActivityForResult(intent, 3);
}

⑦ android 怎么让live wallpaper动态壁纸运行起来

对于Android 2.1来说Live Wallpapers动态壁纸的加入为Android桌面加入了更好的动态效果。如何开发一个Android动态桌面呢? 下面Android123给大家一个详细的步骤创建属于你自己的Live Wallpaper吧。

1. 首先我使用Eclipse创建一个标准的Android工程这里package name我们使用cn.com.android123.cwj,然后进入工程的/res/文件夹,删除layout这个文件夹,当然里面的main.xml也会被删除的,对于Live Wallpaper来说传统的布局文件是不需要的。

2. 类似AppWidget一样,我们可以加入动态壁纸的设置界面,我们在/res/文件夹中新建一个名为xml的文件夹,新建一个utf8编码的xml文件,名为livewallpaper.xml,内容为

<?xml version="1.0" encoding="utf-8"?>
<wallpaper xmlns:android="http://schemas.android.com/apk/res/android"
android:settingsActivity="cn.com.android123.cwj.LiveWallpaperSettings"
android:thumbnail="@drawable/icon"/>
这里我们可以看到上面的节点名为wallpaper,而设置的界面为 cn.com.android123.cwj.LiveWallpaperSettings 这个Activity,而在添加动态壁纸时显示图标为/res/drawable/icon 这个文件,同时我们再创建一个xml文件用于LiveWallpaperSettings这个Activity的布局,我们起名为livewallpaper_settings.xml内容为
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/livewallpaper_settings"
android:key="livewallpaper_settings">

<ListPreference
android:key="livewallpaper_testpattern"
android:title="标题"
android:summary="简单描述"
android:entries="@array/livewallpaper_testpattern_names"
android:entryValues="@array/livewallpaper_testpattern_prefix"/>

<CheckBoxPreference android:key="livewallpaper_movement"
android:summary="动态描述"
android:title="动态标题"
android:summaryOn="动态测试"
android:summaryOff="静止测试"/>
</PreferenceScreen>
3. 创建一个名为LiveWallpaper的类作为动态壁纸的主类,从WallpaperService父类继承,这里我们可以像写标准Android服务那样开发
4. 新建类LiveWallpaperSettings从 PreferenceActivity 继承实现我们的设置界面,代码如下
public class LiveWallpaperSettings extends PreferenceActivity implements
SharedPreferences. {
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
getPreferenceManager().setSharedPreferencesName(
LiveWallpaper.SHARED_PREFS_NAME);
addPreferencesFromResource(R.xml.livewallpaper_settings);
getPreferenceManager().getSharedPreferences()
.register(this);
}

@Override
protected void onResume() {
super.onResume();
}

@Override
protected void onDestroy() {
getPreferenceManager().getSharedPreferences()
.unregister(this);
super.onDestroy();
}

public void onSharedPreferenceChanged(SharedPreferences sharedPreferences,
String key) {
}
}
同时仍然在androidmanifest.xml中加入 下面的代码。
<activity android:label="@string/livewallpaper_settings"
android:name=".LiveWallpaperSettings"
android:theme="@android:style/Theme.Light.WallpaperSettings"
android:exported="true"
android:icon="@drawable/icon">
</activity>
5. 由于Android动态壁纸是2.1 API Level为7才加入的,所以设置好minSDK以及需要设备支持动态壁纸,我们在androidmanifest.xml中加入
<uses-sdk android:minSdkVersion="7" />
<uses-feature android:name="android.software.live_wallpaper" />
6. 对于文中ListPreference用到的数组,及代码中涉及的颜色数组,我们在/res/values/ 文件夹中创建一个名为testpatterns.xml 的文件,内容为
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<string-array name="livewallpaper_testpattern_names">
<item>"Color Bars 16x9"</item>
<item>"Color Bars 4x3"</item>
<item>"EBU Color Bars"</item>
</string-array>

<string-array name="livewallpaper_testpattern_prefix">
<item>"smpte"</item>
<item>"bars"</item>
<item>"ebu"</item>
</string-array>

<integer-array name="smptecolors">
<item>0xFF696969</item>
<item>0xFFC1C1C1</item>
<item>0xFFC1C100</item>
<item>0xFF00C1C1</item>
<item>0xFF00C100</item>
<item>0xFFC100C1</item>
<item>0xFFC10000</item>
<item>0xFF0000C1</item>
<item>0xFF696969</item>
<item>0xFF00FFFF</item>
<item>0xFFFFFF00</item>
<item>0xFF052550</item>
<item>0xFF36056D</item>
<item>0xFF0000FF</item>
<item>0xFFFF0000</item>
<item>0xFFC1C1C1</item>
<item>0xFF2B2B2B</item>
<item>0xFF050505</item>
<item>0xFFFFFFFF</item>
<item>0xFF050505</item>
<item>0xFF000000</item>
<item>0xFF050505</item>
<item>0xFF0A0A0A</item>
<item>0xFF050505</item>
<item>0xFF0D0D0D</item>
<item>0xFF050505</item>
<item>0xFF2b2b2b</item>
</integer-array>

<integer-array name="barscolors">
<item>0xFFC0C0C0</item>
<item>0xFFC0C000</item>
<item>0xFF00C0C0</item>
<item>0xFF00C000</item>
<item>0xFFC000C0</item>
<item>0xFFC00000</item>
<item>0xFF0000C0</item>
<item>0xFF0000C0</item>
<item>0xFF131313</item>
<item>0xFFC000C0</item>
<item>0xFF131313</item>
<item>0xFF00C0C0</item>
<item>0xFF131313</item>
<item>0xFFC0C0C0</item>
<item>0xFF00214C</item>
<item>0xFFFFFFFF</item>
<item>0xFF32006A</item>
<item>0xFF131313</item>
<item>0xFF090909</item>
<item>0xFF131313</item>
<item>0xFF1D1D1D</item>
<item>0xFF131313</item>
</integer-array>

<integer-array name="ebucolors">
<item>0xFFBFBFBF</item>
<item>0xFFBFBF00</item>
<item>0xFF00BFBF</item>
<item>0xFF00BF00</item>
<item>0xFFBF00BF</item>
<item>0xFFBF0000</item>
<item>0xFF0000BF</item>
<item>0xFF000000</item>
</integer-array>
</resources>

转载

⑧ 使用编码的android我怎样才能设置壁纸

要设置的墙纸在下面code的android应用:通过使用WallpaperManager类
按钮buttonSetWallpaper =(按钮)findViewById(R.id.set);
ImageView的图像preVIEW =(ImageView的)findViewById(R.id. preVIEW);
像preview.setImageResource(R.drawable.five);
buttonSetWallpaper.setOnClickListener(新Button.OnClickListener(){
@覆盖
公共无效的onClick(查看为arg0){
// TODO自动生成方法存根
WallpaperManager myWallpaperManager
= WallpaperManager.getInstance(getApplicationContext());
尝试 {
myWallpaperManager.setResource(R.drawable.five);
}赶上(IOException异常E){
// TODO自动生成的catch块
e.printStackTrace();
}
}
});

热点内容
两位数密码要试多少次能试出来 发布:2024-05-02 11:30:59 浏览:688
ae脚本插件表达式 发布:2024-05-02 11:26:45 浏览:267
手机电脑通用的服务器 发布:2024-05-02 11:25:26 浏览:839
安卓b站账号如何在ios登陆 发布:2024-05-02 11:20:29 浏览:198
微信加密码锁怎么设置 发布:2024-05-02 11:17:24 浏览:584
四川服务器托管云空间云主机 发布:2024-05-02 11:04:28 浏览:962
手机app重编译 发布:2024-05-02 11:01:40 浏览:537
怎么给订制系统平板安装安卓系统 发布:2024-05-02 10:29:59 浏览:260
云服务器做网站服务器用什么系统 发布:2024-05-02 10:20:26 浏览:896
python经典程序实例 发布:2024-05-02 09:42:07 浏览:260