我需要做一个非常简单的事情 - 找出是否显示了软件键盘.这在Android中可行吗?
在Android中,我所定义的ImageView的layout_width是fill_parent(可能需要在电话的全宽).
如果我放的图像ImageView大于layout_width,那么Android会缩放它,对吧?但身高呢?当Android缩放图像时,它会保持纵横比吗?
我发现,ImageView当Android缩放比图像大的图像时,顶部和底部有一些空白区域ImageView.真的吗?如果是,我该如何消除那个空白区?
我想在Android应用程序上做一些简单的事情.怎么可能回到以前的活动.
我需要什么代码才能回到之前的活动
我已经看了看文档与摇篮建设,但我仍然不知道什么之间的差异compileSdkVersion,并targetSdkVersion为.
它只是说:
该
compileSdkVersion属性指定编译目标.
那么,"汇编目标"是什么?
我看到两种可能的解释方式:
compileSdkVersion在构建应用程序所使用的编译器的版本,同时targetSdkVersion是"API级别的应用程序的目标".(如果是这种情况,我认为compileSdkVersion必须大于或等于targetSdkVersion?我看到之前已经问过这个问题,但是一个答案只引用了文档,这对我来说是不清楚的.
从我上一个项目更新后出现错误.我的代码不是问题,但我在build.gradle时遇到问题.我该如何解决?
build.gradle代码在这里:
apply plugin: 'android'
android {
compileSdkVersion 21
buildToolsVersion '20.0.0'
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
}
defaultConfig {
applicationId 'com.xxx.axxx'
minSdkVersion 14
targetSdkVersion 19
versionCode 6
versionName '1.0'
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:19.+'
compile files('libs/commons-codec-1.8.jar')
compile files('libs/asmack-android-8-4.0.4.jar')
compile 'com.android.support:support-v4:21.0.0'
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.jakewharton:butterknife:5.1.1'
}
Run Code Online (Sandbox Code Playgroud)
Gradle Sync消息输出: …
是否可以在Java for Android中实现模型 - 视图 - 控制器模式?
或者它是否已通过活动实施?或者有更好的方法来实现Android的MVC模式?
我想让我的Gradle构建使用Gradle创建一个发布签名的apk文件.
我不确定代码是否正确或者我在做gradle build什么时缺少参数?
这是我的gradle文件中的一些代码:
android {
...
signingConfigs {
release {
storeFile file("release.keystore")
storePassword "******"
keyAlias "******"
keyPassword "******"
}
}
}
Run Code Online (Sandbox Code Playgroud)
gradle构建完成SUCCESSFUL,在我的build/apk文件夹中我只看到...-release-unsigned.apk和...-debug-unaligned.apk文件.
关于如何解决这个问题的任何建议?
我有这个问题,我在平板电脑项目中使用Android的Holo主题.但是,我在屏幕上有一个具有白色背景的片段.我EditText在这个片段上添加了一个组件.我试图通过设置Holo.Light主题资源的背景来覆盖主题.但是,我的文本光标(克拉)仍然是白色的,因此在屏幕上看不见(我可以在编辑文本字段中隐约发现它...).
有谁知道如何让EditText使用更暗的光标颜色?我已经尝试将EditText的样式设置为"@android:style/Widget.Holo.Light.EditText"没有正面结果.
一直试图改变材质的浮动动作按钮颜色,但没有成功.
<android.support.design.widget.FloatingActionButton
android:id="@+id/profile_edit_fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end|bottom"
android:layout_margin="16dp"
android:clickable="true"
android:src="@drawable/ic_mode_edit_white_24dp" />
Run Code Online (Sandbox Code Playgroud)
我试过补充一下
android:background="@color/mycolor"
Run Code Online (Sandbox Code Playgroud)
或通过代码
FloatingActionButton fab = (FloatingActionButton) rootView.findViewById(R.id.profile_edit_fab);
fab.setBackgroundColor(Color.parseColor("#mycolor"));
Run Code Online (Sandbox Code Playgroud)
要么
fab.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#mycolor")));
Run Code Online (Sandbox Code Playgroud)
但以上都没有奏效.我也在"重复的问题"中尝试了解决方案,但它们都没有工作,按钮保持绿色并且也变成了正方形.
我想详细解答一下,谢谢.
PS知道如何添加涟漪效果也不错,也无法理解.
我动态地在我的android项目中创建所有元素.我试图获得按钮的宽度和高度,以便我可以旋转该按钮.我只是想学习如何使用android语言.但是,它返回0.
我做了一些研究,我发现它需要在onCreate()方法之外的某个地方完成.如果有人能给我一个如何做的例子,那就太好了.
这是我目前的代码:
package com.animation;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.Button;
import android.widget.LinearLayout;
public class AnimateScreen extends Activity {
//Called when the activity is first created.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
layoutParams.setMargins(30, 20, 30, 0);
Button bt = new Button(this);
bt.setText(String.valueOf(bt.getWidth()));
RotateAnimation ra = new RotateAnimation(0,360,bt.getWidth() / 2,bt.getHeight() / 2);
ra.setDuration(3000L);
ra.setRepeatMode(Animation.RESTART);
ra.setRepeatCount(Animation.INFINITE);
ra.setInterpolator(new LinearInterpolator());
bt.startAnimation(ra);
ll.addView(bt,layoutParams);
setContentView(ll);
} …Run Code Online (Sandbox Code Playgroud)