我是newbi所以请耐心等待:)
为什么我看不到布局上的组件?
我打开一个现有的项目,所有编译并且看起来不错。我打开了其中一个布局,我在组件树中看到了一些组件,但在设计器中我看到了android ... ActionBarOverylayLayout。 如何查看组件? 我的gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
defaultConfig {
applicationId "com.adafruit.bluefruit.le.connect"
minSdkVersion 19
targetSdkVersion 24
versionCode 17
versionName "2.2.1"
}
useLibrary 'org.apache.http.legacy' // TODO: remove Apache library and use HttpURLConnection (Apache is deprecated since Android 6.0)
aaptOptions {
noCompress "zip"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
maven {
url "https://repo.eclipse.org/content/repositories/paho-releases/"
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'no.nordicsemi.android:dfu:1.0.4'
compile(group: 'org.eclipse.paho', name: 'org.eclipse.paho.android.service', version: '1.0.2') {
exclude module: 'support-v4'
}
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.larswerkman:HoloColorPicker:1.4'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services-analytics:9.6.1'
compile 'com.google.android.gms:play-services-location:9.6.1'
compile 'com.google.android.gms:play-services-vision:9.6.1'
}
布局xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/default_background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.adafruit.bluefruit.le.connect.app.UartActivity">
<LinearLayout
android:id="@+id/sendLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cccccc"
android:orientation="horizontal">
<EditText
android:id="@+id/sendEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textNoSuggestions|textVisiblePassword"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical"
android:singleLine="false" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClickSend"
android:text="@string/uart_send" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="4dp"
android:orientation="horizontal">
<TextView
android:id="@+id/sentBytesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/uart_sentbytes_format"
android:textColor="@drawable/default_infotextcolor" />
<TextView
android:id="@+id/receivedBytesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@string/uart_receivedbytes_format"
android:textColor="@drawable/default_infotextcolor" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@id/sendLayout"
android:layout_alignParentTop="true"
android:orientation="vertical">
<!--
android:layout_below="@id/headerLayout"
android:layout_marginTop="10dp"
!-->
<ListView
android:id="@+id/bufferListView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#cccccc" />
<EditText
android:id="@+id/bufferTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#cccccc"
android:cursorVisible="false"
android:gravity="top"
android:scrollbarFadeDuration="0"
android:textColorHighlight="#ffffff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickCopy"
android:text="@string/uart_copy"
android:textColor="@drawable/default_textcolor" />
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickShare"
android:text="@string/uart_share"
android:textColor="@drawable/default_textcolor" />
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickClear"
android:text="@string/uart_clear"
android:textColor="@drawable/default_textcolor" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:0)
答案 1 :(得分:0)
你在id资源中缺少'+'
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/default_background"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.adafruit.bluefruit.le.connect.app.UartActivity">
<LinearLayout
android:id="@+id/sendLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cccccc"
android:orientation="horizontal">
<EditText
android:id="@+id/sendEditText"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:inputType="textNoSuggestions|textVisiblePassword"
android:scrollbarAlwaysDrawVerticalTrack="true"
android:scrollbars="vertical"
android:singleLine="false" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClickSend"
android:text="@string/uart_send" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:layout_marginTop="4dp"
android:orientation="horizontal">
<TextView
android:id="@+id/sentBytesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/uart_sentbytes_format"
android:textColor="@drawable/default_infotextcolor" />
<TextView
android:id="@+id/receivedBytesTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:text="@string/uart_receivedbytes_format"
android:textColor="@drawable/default_infotextcolor" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/sendLayout" //here change
android:layout_alignParentTop="true"
android:orientation="vertical">
<!--
android:layout_below="@id/headerLayout"
android:layout_marginTop="10dp"
!-->
<ListView
android:id="@+id/bufferListView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#cccccc" />
<EditText
android:id="@+id/bufferTextView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#cccccc"
android:cursorVisible="false"
android:gravity="top"
android:scrollbarFadeDuration="0"
android:textColorHighlight="#ffffff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickCopy"
android:text="@string/uart_copy"
android:textColor="@drawable/default_textcolor" />
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickShare"
android:text="@string/uart_share"
android:textColor="@drawable/default_textcolor" />
<Button
style="?android:attr/borderlessButtonStyle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickClear"
android:text="@string/uart_clear"
android:textColor="@drawable/default_textcolor" />
</LinearLayout>
</LinearLayout>
还会更新SDK工具并尝试在菜单文件中 - &gt;无效的缓存/重启