<legend id='fx3Pg'><style id='fx3Pg'><dir id='fx3Pg'><q id='fx3Pg'></q></dir></style></legend>
  • <small id='fx3Pg'></small><noframes id='fx3Pg'>

        <tfoot id='fx3Pg'></tfoot>
        <i id='fx3Pg'><tr id='fx3Pg'><dt id='fx3Pg'><q id='fx3Pg'><span id='fx3Pg'><b id='fx3Pg'><form id='fx3Pg'><ins id='fx3Pg'></ins><ul id='fx3Pg'></ul><sub id='fx3Pg'></sub></form><legend id='fx3Pg'></legend><bdo id='fx3Pg'><pre id='fx3Pg'><center id='fx3Pg'></center></pre></bdo></b><th id='fx3Pg'></th></span></q></dt></tr></i><div id='fx3Pg'><tfoot id='fx3Pg'></tfoot><dl id='fx3Pg'><fieldset id='fx3Pg'></fieldset></dl></div>

          <bdo id='fx3Pg'></bdo><ul id='fx3Pg'></ul>

        Android:如何创建自定义按钮小部件

        时间:2023-09-08
          <tbody id='mfLSx'></tbody>
          <tfoot id='mfLSx'></tfoot>
          • <bdo id='mfLSx'></bdo><ul id='mfLSx'></ul>
            <i id='mfLSx'><tr id='mfLSx'><dt id='mfLSx'><q id='mfLSx'><span id='mfLSx'><b id='mfLSx'><form id='mfLSx'><ins id='mfLSx'></ins><ul id='mfLSx'></ul><sub id='mfLSx'></sub></form><legend id='mfLSx'></legend><bdo id='mfLSx'><pre id='mfLSx'><center id='mfLSx'></center></pre></bdo></b><th id='mfLSx'></th></span></q></dt></tr></i><div id='mfLSx'><tfoot id='mfLSx'></tfoot><dl id='mfLSx'><fieldset id='mfLSx'></fieldset></dl></div>

            1. <small id='mfLSx'></small><noframes id='mfLSx'>

                1. <legend id='mfLSx'><style id='mfLSx'><dir id='mfLSx'><q id='mfLSx'></q></dir></style></legend>

                  本文介绍了Android:如何创建自定义按钮小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想创建一个具有圆形或矩形背景、文本和文本下方或上方的图像的按钮.

                  I would like to create a button with circular or rectangular background, text and an image below or above the text.

                  这是我添加对象的 CustomButton 布局(背景和文本 - ImageView 缺失):

                  Here is the CustomButton Layout where I added the objects (background and text - ImageView is missing):

                  <FrameLayout
                   xmlns:android="http://schemas.android.com/apk/res/android"
                   android:layout_height="wrap_content"
                   android:orientation="horizontal" android:layout_width="wrap_content" android:layout_gravity="center_vertical|center_horizontal">
                  

                  我想使用 setText() 和 setImage() 方法创建一个 CustomButton 对象,这将更改按钮文本和图像并将多个 CustomButtons 放置到主布局中.

                  I would like to create a CustomButton object with methods setText() and setImage() which would change the button text and image and place multiple CustomButtons into main layout.

                  有谁知道如何创建自定义布局,将其放入另一个布局(主)并从绑定到主布局的活动中修改其元素?

                  Does anyone know how to create a custom layout, place it into another layout(main) and modify its elements from the activity which is bound to main layout?

                  非常感谢您的帮助.

                  谢谢!

                  推荐答案

                  如果你想要编程访问,你应该继承 View 并在 java 中完成你的工作.您仍然可以在 xml 中进行布局,但具有您想要的图像和文本方法.然后,您将能够在另一个布局中使用它来放置您的自定义按钮.

                  If you want programmatic access, you should subclass View and do your work there in java. You can still do the layout in xml, but have the image and text methods that you want. You will then be able to use this in another layout to place your CustomButtons.

                  这篇关于Android:如何创建自定义按钮小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在小部件中动态设置 ImageView 的圆角? 下一篇:如何将 MediaBrowserService 与小部件一起使用?

                  相关文章

                  <legend id='ToskQ'><style id='ToskQ'><dir id='ToskQ'><q id='ToskQ'></q></dir></style></legend>

                      <tfoot id='ToskQ'></tfoot>

                      <small id='ToskQ'></small><noframes id='ToskQ'>

                        <bdo id='ToskQ'></bdo><ul id='ToskQ'></ul>

                      <i id='ToskQ'><tr id='ToskQ'><dt id='ToskQ'><q id='ToskQ'><span id='ToskQ'><b id='ToskQ'><form id='ToskQ'><ins id='ToskQ'></ins><ul id='ToskQ'></ul><sub id='ToskQ'></sub></form><legend id='ToskQ'></legend><bdo id='ToskQ'><pre id='ToskQ'><center id='ToskQ'></center></pre></bdo></b><th id='ToskQ'></th></span></q></dt></tr></i><div id='ToskQ'><tfoot id='ToskQ'></tfoot><dl id='ToskQ'><fieldset id='ToskQ'></fieldset></dl></div>