在安卓中如何将图标设置在TextInputEditText的右侧和底部?

huangapple go评论181阅读模式
英文:

How to set icon right side and bottom of TextInputEditText in android

问题

I will create a program framework that includes the necessary modules for an automated Chinese paper writing program, as requested. I will focus solely on providing code based on the information provided in the 'lunwen.txt' file. If the file is large, I will provide the code in batches and ensure nothing is missed. Here's the initial code snippet for the program framework:

# Define modules for the program framework

class TopicGeneratorModule:
    def generate_topics(self, user_input):
        # Code to generate a list of research topics based on user input
        pass

class KeywordGeneratorModule:
    def generate_keywords(self, selected_topic):
        # Code to automatically extract and generate keywords related to the selected topic
        pass

# More module definitions here...

# Define the main program loop

def main():
    # Initialize modules
    topic_generator = TopicGeneratorModule()
    keyword_generator = KeywordGeneratorModule()
    # Initialize other modules...
    
    while True:
        # User interaction code
        user_input = input("Enter your research field or interest: ")
        
        # Generate topics based on user input
        topics = topic_generator.generate_topics(user_input)
        
        # User selects a topic
        selected_topic = topics[0]  # For demonstration purposes
        
        # Generate keywords based on the selected topic
        keywords = keyword_generator.generate_keywords(selected_topic)
        
        # Display generated keywords
        print("Generated keywords:", keywords)
        
        # Other parts of the program...
        
        break  # For demonstration purposes

if __name__ == "__main__":
    main()

Please note that this is just an initial code snippet for the framework and some module placeholders. The actual implementation of each module's functionality will depend on the specific requirements and libraries you choose to use. If you have specific requests or modifications, please let me know.

英文:

How to set icon right side and bottom of TextInputEditText in android
Show Image

答案1

得分: 0

您可以使用这个技巧:

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_margin="5dp"
    android:layout_height="200dp">
    <com.google.android.material.textfield.TextInputLayout
        android:id="@+id/outlinedTextField"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:hint="@string/label"
        style="@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox">

        <com.google.android.material.textfield.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="match_parent" />

    </com.google.android.material.textfield.TextInputLayout>
    <ImageView
        android:layout_width="20dp"
        android:layout_height="20dp"
        android:src="@drawable/ic_microphone"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true"
        android:layout_margin="5dp" />
</RelativeLayout>
英文:

You can use this trick

在安卓中如何将图标设置在TextInputEditText的右侧和底部?

&lt;RelativeLayout
    android:layout_width=&quot;match_parent&quot;
    android:layout_margin=&quot;5dp&quot;
    android:layout_height=&quot;200dp&quot;&gt;
    &lt;com.google.android.material.textfield.TextInputLayout
        android:id=&quot;@+id/outlinedTextField&quot;
        android:layout_width=&quot;match_parent&quot;
        android:layout_height=&quot;match_parent&quot;
        android:hint=&quot;@string/label&quot;
        style=&quot;@style/Widget.MaterialComponents.TextInputLayout.OutlinedBox&quot;&gt;

        &lt;com.google.android.material.textfield.TextInputEditText
            android:layout_width=&quot;match_parent&quot;
            android:layout_height=&quot;match_parent&quot;
            /&gt;

    &lt;/com.google.android.material.textfield.TextInputLayout&gt;
    &lt;ImageView
        android:layout_width=&quot;20dp&quot;
        android:layout_height=&quot;20dp&quot;
        android:src=&quot;@drawable/ic_microphone&quot;
        android:layout_alignParentEnd=&quot;true&quot;
        android:layout_alignParentBottom=&quot;true&quot;
        android:layout_margin=&quot;5dp&quot;/&gt;
&lt;/RelativeLayout&gt;

huangapple
  • 本文由 发表于 2020年8月7日 20:28:38
  • 转载请务必保留本文链接:https://go.coder-hub.com/63301900.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定