我有一个按钮,有2个不同的图片,用于按下和释放状态.如何以编程方式切换状态?
我正在将我的Android项目从Java转换为Kotlin.我已经成功完成了其他3个项目的这个过程.
但这个有点大,结构复杂.我已经将一些文件转换为Kotlin和项目编译.但是当我将它们转换为Kotlin时,有些文件会抛出编译异常.
我面临的编译问题出现在调试和发布模式中.简短如下(已在下面列出)
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:compileDebugKotlin'.
Caused by: org.gradle.api.GradleException: Compilation error. See log for more details
Run Code Online (Sandbox Code Playgroud)
您怎么看,我该如何解决这个问题?
我认为这是Android Studio中的一个错误.
我试过了.没有任何结果:
我的app build.gradle是:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
apply plugin: 'kotlin-android'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 15
targetSdkVersion 25
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
applicationId "package.id"
versionCode …Run Code Online (Sandbox Code Playgroud) 即使这个问题在stackoverflow中有很多解决方案,我也无法解决我的问题。我在屏幕上有两个编辑文本,一个在顶部,另一个附加在屏幕底部。每当我点击底部编辑文本时,软键盘就会出现在它上面。我已经玩过 windowSoftInputMode。
当我单击底部的编辑文本时,我不希望屏幕的其他内容向上滚动。
这是我的 xml 布局。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:background="@color/background"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="@+id/phone_number_edit_text_compose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="@dimen/activity_horizontal_margin"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_toLeftOf="@id/select_contact"
android:background="@drawable/phone_edittext_background_selector"
android:ems="10"
android:hint="@string/phone_edittext_hint"
android:inputType="phone"
android:paddingBottom="12dp"
android:paddingLeft="8dp"
android:paddingTop="12dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/white" />
<ImageButton
android:id="@+id/selectcontact_compose"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignBottom="@+id/phone_number_edit_text_compose"
android:layout_marginTop="@dimen/activity_horizontal_margin"
android:layout_toRightOf="@id/phone_number_edit_text_compose"
android:background="@drawable/select_contact_background_selector"
android:contentDescription="@string/select_contact_content_description"
android:src="@drawable/select_contact_selector"
android:layout_marginLeft="2dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"/>
<View
android:id="@+id/view1"
android:layout_width="wrap_content"
android:layout_height="2px"
android:layout_below="@id/phone_number_edit_text_compose"
android:layout_marginTop="@dimen/redial_screen_distance_between_views"
android:background="@drawable/separator" />
<LinearLayout
android:id="@+id/repetition_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/view1"
android:clickable="true"
android:onClick="RepetitionLayoutClickListener"
android:orientation="horizontal"
android:paddingBottom="@dimen/redial_screen_distance_between_views"
android:paddingTop="@dimen/redial_screen_distance_between_views"
android:background="@drawable/repetition_layout_background_selector"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin">
<TextView
android:id="@+id/repetition_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/repetition" …Run Code Online (Sandbox Code Playgroud) xml android android-layout window-soft-input-mode android-relativelayout