我的XML布局有问题,我认为这不会给我带来很多问题.我在滚动视图中有一个布局,但布局的底部被切断,我看不到第二个列表视图之外的任何内容.从环顾四周看,我似乎无法看到xml本身有什么问题,我看不出我做错了什么.
我已经尝试了对问题的建议,即为每个不同的元素添加权重,但这仍然没有解决问题.
我还添加了可能有助于解决问题的片段所在的主要活动
片段XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/coordinatorLayout">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fillViewport="true"
android:scrollbars="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Recipe Title"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="@+id/ingredientsHeading"
android:layout_below="@+id/text_input_layout"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="Ingredients"
android:textStyle="bold|italic"
android:layout_weight="1" />
<ListView
android:id="@+id/ingredientsList"
android:layout_below="@+id/ingredientsHeading"
android:layout_above="@+id/directionsHeading"
android:layout_width="wrap_content"
android:layout_height="195dp"
android:layout_weight="1"></ListView>
<Button style="@style/Button"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:text="Add Ingredient"
android:id="@+id/addIngredient"
android:layout_below="@+id/ingredientsList"
android:enabled="true"
android:layout_gravity="center_horizontal"
android:layout_weight="1" />
<TextView
android:id="@+id/directionsHeading"
android:layout_below="@+id/addIngredient"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:text="Directions"
android:textStyle="bold|italic"
android:layout_weight="1" />
<ListView
android:id="@+id/directionsList"
android:layout_below="@+id/directionsHeading"
android:layout_width="wrap_content"
android:layout_height="195dp"
android:layout_weight="1"></ListView> …Run Code Online (Sandbox Code Playgroud) android android-layout android-xml android-fragments android-studio
我正在使用新Theme.AppCompat.DayNight添加的Android Support Library 23.2
在Android 5.1上运行良好.
在Android 6.0上,活动看起来像使用灯光主题,但对话框看起来使用黑暗主题.
我的应用类:
public class MyApplication extends Application {
static {
AppCompatDelegate.setDefaultNightMode(
AppCompatDelegate.MODE_NIGHT_YES);
}
}
Run Code Online (Sandbox Code Playgroud)
我的styles.xml
<style name="AppTheme" parent="Theme.AppCompat.DayNight">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="Dialog.Alert" parent="Theme.AppCompat.DayNight.Dialog.Alert"/>
Run Code Online (Sandbox Code Playgroud)
我的代码显示一个对话框:
new AlertDialog.Builder(mContext, R.style.Dialog_Alert)
.setTitle("Title")
.setMessage("Message")
.show();
Run Code Online (Sandbox Code Playgroud) xml android android-layout android-theme android-support-library
在我的项目中,我正在尝试使用设计支持库.我有我的Gradle文件:
dependencies {
....
compile 'com.android.support:design'
....
}
Run Code Online (Sandbox Code Playgroud)
当我尝试构建它时,我得到错误:
通常我会点击Install Repository and sync project,但是,这似乎不再起作用了.即使单击Open File工作正常,单击此操作也绝对没有任何作用.
我该如何手动安装它?
我安装了最新的Android支持存储库(30.0.0)和Android支持库(23.2.1).
在Android 6.0 Marshmallow上,EditText相对于RelativeLayout中的ImageView与属性baseline和layout_alignBaseline的定位不再起作用.甚至可以在Android studio的布局编辑器中观察到这种行为.在一个真正的Android Marshmallow设备或emulatr上,我的情况下EditText移出屏幕并且不可见.我是否会错过一些更改,这是一个错误吗?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivityFragment">
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:id="@+id/imageView"
android:src="@drawable/icon_category_geography_raster"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:baselineAlignBottom="true"
android:background="#00ffff"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/editText"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/imageView"
android:background="#ff0000"
android:inputType="text"
android:hint="Hint"
android:layout_alignBaseline="@id/imageView" />
Run Code Online (Sandbox Code Playgroud)
我创建了Android Studio布局编辑器的截图.这两个屏幕截图之间的区别仅在于API级别的更改.
我创建了一个示例项目 https://github.com/mikegr/baseline
android android-layout android-relativelayout android-6.0-marshmallow
如何在我的Android应用程序中实现选项菜单?我尝试了Android Developer的代码,但是我收到了错误.如下:必须声明元素菜单.这是我的代码
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:icon="@drawable/ic_new_game"
android:title="@string/new_game"
android:showAsAction="ifRoom"/>
<item android:id="@+id/help"
android:icon="@drawable/ic_help"
android:title="@string/help" />
</menu>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.lucavanraalte.test" >
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme" >
<activity android:name=".MainActivity" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Run Code Online (Sandbox Code Playgroud)
android android-manifest android-layout oncreateoptionsmenu android-studio
在Android-Studio中创建新的Java Keystore很容易.但是我想在这个Keystore中添加第二个Alias.对于同一客户的第二个应用程序.我怎么做?或者,如果这是一个不太好的想法,那么更好的方法是什么?
编辑:我不打算对同一个项目使用不同的密钥库.第一个项目在Android Studio中完成,第二个项目在Intel XDK中完成.他们不会共享进程或需要访问另一方的数据.
我有这个评级栏,它在应用程序内部,并始终正确显示.但最近我意识到它在某些设备上无法正常工作(其中包括带有Lollipop版本的Nexus 5).评级栏由黑色覆盖覆盖,如下图所示(仅在某些设备上).当滚动列表视图(带有评级星标)时,将显示评级栏(然后再次显示黑色叠加).它只影响黄色星星而不影响白色星星.
我不确定以前有没有人遇到过这个问题?我在想是否是Nexus 5最近的Android更新导致这一点,因为评级栏在其他设备上运行良好.

几乎一周后我运行了我的android项目,我收到了这条消息:
插件太旧,请更新到更新版本,或将ANDROID_DAILY_OVERRIDE环境变量设置为"a8faa180fc282060c9b8ec88f9bdcc9072121284"
如何更新我的插件?我正在使用android Studio 2.0.这是我的build.gradle项目文件
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud) plugins dependencies android android-studio android-gradle-plugin
我有PSD,分辨率是1080X1920,它包含一个Dot分辨率为的图像22X22.
我已裁剪该图像并将其放入我的res文件夹中.
我的问题是Android如何知道图像是用于1080X1920屏幕的.它会在small屏幕上打开相同的图像,2560x1440分辨率更小.
有没有办法,除了为每个屏幕尺寸放置不同的图像,告诉Android使用图像的特定屏幕尺寸和规模为其他 screens
android ×10
xml ×2
alias ×1
android-xml ×1
dependencies ×1
image ×1
image-size ×1
java ×1
keystore ×1
plugins ×1
ratingbar ×1