小编PLN*_*ech的帖子

布局的边框

我试图围绕我的布局制作边框

两个带圆角边框的文本区域

但我正在尝试改变布局颜色.没有任何边界.

我的代码是

<?xml version="1.0" encoding="UTF-8"?> 
<shape xmlns:android="http://schemas.android.com/apk/res/android"
> 

<stroke android:width="1dp"

        android:color="#eedfcc"
        android:background="#000080"/>

<corners android:bottomRightRadius="20dp"
         android:bottomLeftRadius="20dp" 
         android:topLeftRadius="10dp"
         android:topRightRadius="8dp"/> 
</shape>
Run Code Online (Sandbox Code Playgroud)

为什么它不起作用?

android border android-linearlayout

13
推荐指数
1
解决办法
4万
查看次数

我怎样才能"un-JsonIgnore"派生类中的属性?

我正在使用Newtonsoft的JsonSerializer来序列化一些类.

由于我想在序列化过程中省略我的类的一个字段,我将其声明如下:

[JsonIgnore]
public int ParentId { get; set; }
Run Code Online (Sandbox Code Playgroud)

这有效,但我现在面临一个新问题:在派生类中,我希望这个字段出现(并且在这个特定的派生类中这样做).

我一直在浏览文档和互联网上的方法来覆盖子类中的这个设置(我想我需要类似的东西[JsonStopIgnore],但我找不到任何接近的东西).


  • 有什么办法让我强行JsonSerializer再次拿起这个属性吗?
  • 是否可以将属性明确标记为[JsonIgnore],但仅限于基类?

.net c# json jsonserializer json.net

13
推荐指数
4
解决办法
4183
查看次数

FrameLayout中的'android:foreground'和'android:foregroundGravity'如何影响其外观?

FrameLayout具有属性android:foreground,android:foregroundGravityandroid:measureAllChildren.我已经尝试过这些属性,但无法弄清楚它们如何影响布局的外观或它们的工作方式.

<FrameLayout 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:foreground="@android:color/holo_blue_dark"
 android:foregroundGravity="center"
 android:measureAllChildren="true"
 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.example.framelayoutdemo.MainActivity" >

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world" />

<ImageView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:src="@android:drawable/btn_dialog" />

</FrameLayout>
Run Code Online (Sandbox Code Playgroud)

我用谷歌搜索,但无法找到这些属性的帮助.请给我一个链接,我可以参考或帮助我举个例子.谢谢

android android-framelayout

11
推荐指数
1
解决办法
2万
查看次数

`别名sudo ="sudo"`工作怎么样?

看看将当前用户的别名传递给sudo命令的方法,我在ArchWiki上找到了以下内容:

传递别名

如果您使用了很多别名,您可能已经注意到在使用sudo时它们不会转移到root帐户.但是,有一种简单的方法可以使它们工作.只需将以下内容添加到您 ~/.bashrc/etc/bash.bashrc:

alias sudo='sudo '

我不明白为什么会这样.如果shell不关心两个命令之间有多少空格,这怎么会有效?

手动添加空格时,我认为没有区别:

$ alias e=echo
$ sudo e foo
sudo: e: command not found
$ sudo  e foo              # Manual space addition
sudo: e: command not found # Fail
$ alias sudo="sudo "       # Now with alias
$ sudo e foo
foo                        # Succeeds, but why?
Run Code Online (Sandbox Code Playgroud)

可见别名sudo到sudo + space以某种方式允许传递别名.这部作品zsh,bash并且sh,所以它不是一个特定的壳行为.

这个别名如何运作?

shell alias sudo sh

11
推荐指数
1
解决办法
1736
查看次数

Android数据绑定,与元素类型"TextView"关联的属性"android:text"的值不得包含"<"字符

我正在使用Android数据绑定库.我要求如果绑定数小于10,我需要显示一个零附加(如01,05),否则显示正常数字.

这是我布局的相关部分:

<TextView
     android:id="@+id/tlm_no"
     style="@style/BlackSmallTextStyle"
     android:layout_width="@dimen/study_plan_icon_width"
     android:layout_height="wrap_content"
     android:layout_below="@id/tlm_image"
     android:gravity="center"
     android:fontFamily="sans-serif-light"
     android:text="@{studyPlanDetailVM.studyPlanDetail.learningPlanResource[0] < 10 ? `0` + studyPlanDetailVM.studyPlanDetail.learningPlanResource[0] : studyPlanDetailVM.studyPlanDetail.learningPlanResource[0]}" />
Run Code Online (Sandbox Code Playgroud)

但是当我构建项目时,它会抛出以下错误: The value of attribute “android:text” associated with an element type “TextView” must not contain the '<' character

我该如何解决这个问题?

android android-layout android-databinding

10
推荐指数
1
解决办法
2042
查看次数

SearchView可以同时具有voiceSearchButton和键盘的语音输入吗?

我正在为我的应用程序的搜索界面添加语音搜索功能.目前,它看起来像这样:

初始搜索界面

为了添加语音搜索,我voiceSearchMode在我的可搜索配置中添加了一个,它在SearchView中添加了一个按钮来触发语音对话框.界面现在看起来像这样:

在此输入图像描述

但是,正如您在键盘上看到的那样,,麦克风按钮现已禁用.我找不到任何关于如何再打开它的文档,唯一相关的问题解释了如何明确禁用它.

是否可以同时使用系统的语音搜索对话框键盘的语音输入SearchView

android voice android-softkeyboard searchview

10
推荐指数
1
解决办法
230
查看次数

Android深层链接省略了某些网址

我已成功实现了对我的应用程序的深层链接,但我遇到了问题.

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data
       android:host="*.example.com"
       android:scheme="https"/>
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

此意图过滤器处理所有链接,但我不想捕获某个URL即ie

https://www.example.com/hello/redirect/
Run Code Online (Sandbox Code Playgroud)

到目前为止我尝试了什么:

我尝试输入我想要手动捕获的所有网址

<data
   android:host="*example.com"
   android:scheme="https"
   android:pathPrefix="/m/">
<data
   android:host="*example.com"
   android:scheme="https"
   android:pathPrefix="/c/">
<data
   android:host="*example.com"
   android:scheme="https"
   android:pathPrefix="/p/">
...
Run Code Online (Sandbox Code Playgroud)

但是我的主页网址https://www.example.com不起作用.

如果我使用

android:pathPrefix="/"
Run Code Online (Sandbox Code Playgroud)

然后这将开始再次捕获所有URL,包括我想省略的URL.

我也尝试过使用android:pathPattern,但它无法理解这样复杂的正则表达式^((?!redirect).)*$,当我在字符串和所有字符串中尝试它时,它可以正常工作.

有谁知道如何省略某些网址?

更新:

正如@PLNech 在这里建议的那样,我添加了我需要捕获的所有URL android:pathPrefix并用于android:path: "/"捕获我的主页的URL,即https://www.example.com/

 <data
   android:host="*.example.com"
   android:scheme="https"
   android:path="/"/>
 <data
  android:host="*example.com"
  android:scheme="https"
  android:pathPrefix="/m/">
 <data
  android:host="*example.com"
  android:scheme="https"
  android:pathPrefix="/c/">
 <data
  android:host="*example.com"
  android:scheme="https"
  android:pathPrefix="/p/">
Run Code Online (Sandbox Code Playgroud)

android deep-linking android-manifest

9
推荐指数
2
解决办法
4419
查看次数

未找到Android sys-img-armeabi-v7a-android-23

我一直在使用以下命令安装abi直到今天.

echo y | android update sdk --no-ui --all --filter sys-img-armeabi-v7a-android-23
Run Code Online (Sandbox Code Playgroud)

但现在我收到了以下错误.

Error: Ignoring unknown package filter 'sys-img-armeabi-v7a-android-23'
Warning: The package filter removed all packages. There is nothing to install.
Please consider trying to update again without a package filter.
Run Code Online (Sandbox Code Playgroud)

有人有同样的问题吗?我正在使用Android SDK r24.4.1.

android android-emulator android-sdk-tools

6
推荐指数
1
解决办法
1164
查看次数

如何更改预览?

我在过去的3个小时里一直在编辑愚蠢的android工作室布局,我无法改变预览!

预览选择菜单

由于某种原因,android studio布局被困在磨损广场上!我只是希望我的布局是一个Nexus 6p,但是当我点击它时,它不是改变布局编辑器手机,而是跳转到我的布局 - 普通xml!

如何更改布局编辑器上显示的手机?这给我带来了太多麻烦

android intellij-idea android-layout android-studio

6
推荐指数
2
解决办法
3296
查看次数

使用 Espresso-Intents 测试与 SpeechRecognizer 的交互

我正在向应用程序添加仪器测试。我想测试围绕语音识别的交互:

  • 用户单击按钮 ( R.id.buttonVoice),显示DialogFragment用于语音识别的
  • SpeechRecognizer踢入,聆听用户输入
  • 部分结果显示在对话框中(暂时不测试)
  • 完成后,对话框关闭,识别的语音显示在活动的TextView( R.id.results)

使用Espresso-Intents 进行仪器测试听起来是确保我的测试不依赖于系统的SpeechRecognizer.

这是我的测试,它与intended()存根意图进行相同的交互:

@RunWith(AndroidJUnit4.class)
@LargeTest
public class MainActivityWithPermissionTest {

    @Rule
    public IntentsTestRule intentsTestRule = new IntentsTestRule<>(MainActivity.class);

    @Test
    public void clickInput_sendsSpeakIntentAndDisplaysResults() {
        // stub intent returning recognition results
        intending(hasAction(equalTo(RecognizerIntent.ACTION_RECOGNIZE_SPEECH)))
                .respondWith(new ActivityResult(Activity.RESULT_OK, new Intent().putExtra(
                        SpeechRecognizer.RESULTS_RECOGNITION, new String[]{"I am uttering."})));

        // when clicking on the buttonVoice, thus opening the dialog and starting the speechRecognizer
        onView(withId(R.id.buttonVoice))
                .perform(click());

        // expect the recognition …
Run Code Online (Sandbox Code Playgroud)

android speech-recognition android-intent android-testing android-espresso

6
推荐指数
0
解决办法
278
查看次数