我正在使用 Android Studio Dolphin | 2021.3.1 & 电鳗 | 2022年1月1日
Android studio 更新后花栗鼠 | 2021.2.1 至 Android Studio Dolphin | 2021.3.1 我的所有项目设计预览和布局预览都没有显示。如果有人解决了这个问题请帮助我。
我已经尝试了所有可能的方法,但没有找到任何解决方案。以下是我尝试过的几点
检查下面的屏幕截图,以便每个人都了解我所面临的问题。
提前致谢。
对我来说,某些布局工作正常,但在某些布局中,我收到以下错误,该错误曾经在早期版本的 Android Studio 中工作。
我在 Android 中遇到了同样的问题(Electric Eel | 2022.1.1)。尽管如此,这个问题仍在继续。
现在在新的预览模式的Android Studio 2.2上,没有更多的刷新按钮:
有谁知道如何再次显示它?或者用快捷方式?
编辑:如果我通过示例更改drawable并且更改未显示在布局中,则关闭的唯一方法是关闭并重新启动项目.如果我关闭布局,当我重新打开时,没有任何反应.使用"同步"按钮的结果相同.
android preview android-layout android-studio-2.2 android-layout-editor
我正在使用Eclipse,我刚刚创建了一个带有2个图像按钮的主页(菜单),但是我收到了这个错误:
布局编辑器中的图形预览可能不准确:
不支持Paint.setShadowLayer.
这是什么意思?我该如何解决?
我使用的是API 21.
我正在使用android.support.constraint.ConstraintLayout布局简单卡片的内容视图.
我每次都会在以下情况下随机更改XML:
Design选项卡Preview打开一个窗格时(在这种情况下,在我的更改期间更改会发生更改).随机变化包括:
layout_marginEnd)tools:layout_editor_absoluteX值问题:
请看一下这个文件diff,它是在切换到Design选项卡时自动生成的:

PS.:我的Android Studio版本是2.2.3; 我在macOS Sierra上运行它.
正如所建议的,在制作之后layout_height="match_parent",我不经常修改,但是当我在Layout Design'er中编辑布局时,我的XML仍然搞砸了:
这次我想layout_marginTop通过设计UI 进行设置(所选行是我想要添加的),但我还得到了其他不需要的更改:
layout_marginStart 删除;app:layout_constraintBottom_toBottomOf引用的ID有一个前缀"+"符号,这意味着,这些ID是新声明的,所以当我使用Goto declaration功能时,我将不得不从列表中选择它 - 而不是所需的行为.tools:layout_editor_absoluteX得到补充.我可以忽略它,但仍然 - 不是我想要发生的事情.android android-studio android-constraintlayout android-layout-editor
Android Studio 3.1布局预览无法在当前主题中找到样式"coordinatorLayoutStyle".
Failed to instantiated one or more classes.
Exception shown are :-
java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
Run Code Online (Sandbox Code Playgroud) java android android-layout android-studio android-layout-editor
它曾经不时地工作,但现在放大/缩小布局设计页面的能力完全消失了.布局视图始终保持10%放大,无论我做什么都不会改变.奇怪的是,具有完全相同内容的预览选项卡可以很好地缩放.
这个问题发生在我的所有项目和布局文件中,我尝试多次重启应用程序和我的计算机,将主题从Dracula更改为IntelliJ然后返回,当然,尝试了"invalidate cache and restart"选项,但没有他们的工作.难道我做错了什么?
我正在使用Android Studio 3.2.1 Build#AI-181.5540.7.32.5056338,建于2018年10月8日
仅供参考,这里是设计编辑器页面的屏幕截图,它一直保持这种状态.
目前,Android Studio将XML和Design窗口显示为选项卡式选项.我希望窗口如下.
我拆分了窗户,但是当我在左侧改变时,右侧没有任何改变,直到我在右侧聚焦(点击).它会节省我的时间.
正如您在图片中看到的那样,我对Button的文本进行了更改,但右侧未显示更改.它需要焦点(单击)来更新更改.(我的意思是一旦我点击右侧就会出现变化)
我的Android Studio布局编辑器无法正常工作。在对布局进行更改之后,预览始终会消失并变成完全白屏或冻结(我无法选择任何元素,并且对xml文件所做的更改不可见)。这在任何布局文件中都会发生。使chach无效并重新启动后,我可以再次工作,但是在进行其他更改之后,我又遇到了同样的问题。执行干净的构建也无济于事。
布局编辑器显示以下异常:
java.lang.IllegalArgumentException: object is not an instance of declaring class
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at android.animation.PropertyValuesHolder_Delegate.callMethod(PropertyValuesHolder_Delegate.java:108)
at android.animation.PropertyValuesHolder_Delegate.nCallFloatMethod(PropertyValuesHolder_Delegate.java:143)
at android.animation.PropertyValuesHolder.nCallFloatMethod(PropertyValuesHolder.java)
at android.animation.PropertyValuesHolder.access$400(PropertyValuesHolder.java:38)
at android.animation.PropertyValuesHolder$FloatPropertyValuesHolder.setAnimatedValue(PropertyValuesHolder.java:1387)
at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:990)
at android.animation.ValueAnimator.animateBasedOnTime(ValueAnimator.java:1339)
at android.animation.ValueAnimator.doAnimationFrame(ValueAnimator.java:1471)
at android.animation.AnimationHandler.doAnimationFrame(AnimationHandler.java:146)
at android.animation.AnimationHandler.access$100(AnimationHandler.java:37)
at android.animation.AnimationHandler$1.doFrame(AnimationHandler.java:54)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:947)
at android.view.Choreographer.doCallbacks(Choreographer.java:761)
at android.view.Choreographer_Delegate.doFrame(Choreographer_Delegate.java:66)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.renderAndBuildResult(RenderSessionImpl.java:563)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:425)
at com.android.layoutlib.bridge.BridgeRenderSession.render(BridgeRenderSession.java:120)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:151)
at com.android.ide.common.rendering.api.RenderSession.render(RenderSession.java:133)
at com.android.tools.idea.rendering.RenderTask.lambda$null$8(RenderTask.java:755)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Run Code Online (Sandbox Code Playgroud)
但是我无法理解发生了什么。我什至不确定这个错误是否是我的问题的原因。也许你可以帮忙。
注意:我正在使用Theme.MaterialComponents.Light.NoActionBar …
我知道你设置的时候
tools:text="Sample text"
Run Code Online (Sandbox Code Playgroud)
在a中TextView,您将在Android Studio的预览模式下看到示例文本,但不会在实际应用中看到.我想为a中的项目做这个RecyclerView,但我似乎无法做到.这是我到目前为止所做的:
在RecyclerView(名为content_feed)中:
tools:listitem="@layout/cell_feed"
Run Code Online (Sandbox Code Playgroud)
在单元格中(名称为cell_feed):
tools:showIn="@layout/content_feed"
Run Code Online (Sandbox Code Playgroud)

这是xml文件:
cell_feed.xml
<?xml version="1.0" encoding="utf-8"?>
<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="@dimen/height_feed_cell"
android:layout_marginLeft="@dimen/margin_feed_cell"
android:layout_marginRight="@dimen/margin_feed_cell"
android:orientation="horizontal"
tools:showIn="@layout/content_feed">
<LinearLayout
android:id="@+id/timeLayouts"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="@dimen/alpha_feed_secondary_text"
android:textSize="@dimen/size_feed_secondary_text"
android:id="@+id/startTimeText"
tools:text="8:00 AM"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="@dimen/alpha_feed_secondary_text"
android:textSize="@dimen/size_feed_secondary_text"
android:id="@+id/endTimeText"
tools:text="10:00 AM"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/margin_feed_cell_text"
android:layout_toRightOf="@+id/timeLayouts"
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/margin_bottom_feed_cell_title"
android:textSize="@dimen/size_feed_cell_title"
android:textStyle="bold"
android:id="@+id/titleText"
tools:text="Event title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="@dimen/alpha_feed_secondary_text"
android:textSize="@dimen/size_feed_secondary_text"
android:id="@+id/captionText"
tools:text="Event caption"/>
</LinearLayout>
<CheckBox
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) android android-studio android-recyclerview android-tools-namespace android-layout-editor
我在 Android Studio 中遇到布局预览的奇怪行为。我开发了一个扩展 AppCompatButton 的自定义视图,并且布局是运行时预期的布局,但是,布局预览中的布局未正确显示。特别是,按钮被显示,但没有从自定义属性设置的背景颜色,也没有 drawableStart(根据名为“social”的自定义属性在自定义视图 init 中设置)。有关其他详细信息,请参阅下面的代码。请注意,自定义视图位于作为模块导入主项目的库中。我在这里缺少什么?谢谢 :)
自定义视图代码:
public class SocialButton extends AppCompatButton {
private static final String TAG = SocialButton.class.getSimpleName();
Context mContext;
int backgroundColor;
int socialId;
int textColor;
public SocialButton(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
mContext = context;
TypedArray a = context.getTheme().obtainStyledAttributes(
attrs,
R.styleable.SocialButton,
0, 0);
initDefaults(a);
setIconForSocial();
initStateListDrawable();
}
public void initDefaults(TypedArray a){
try {
backgroundColor = a.getColor(R.styleable.SocialButton_backgroundColor, Color.WHITE);
textColor = a.getColor(R.styleable.SocialButton_textColor,
ContextCompat.getColor(mContext,R.color.social_button_text_color));
socialId = a.getInt(R.styleable.SocialButton_social, 0);
} finally {
a.recycle();
}
} …Run Code Online (Sandbox Code Playgroud)