Preconfigured Webview to make embedding tweets simple.
Add this library from Jitpack
Add this in your root build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Then add this dependency
dependencies {
implementation 'com.github.yashx:AndroidTweetEmbed:1.0.0'
}
You can try the sample app (apk) and read the code here
Add this view to your layout file
<com.github.yashx.android_tweet_embed.AndroidTweetEmbed
android:id="@+id/androidTweetEmbed"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Find a reference to it and use any of following two methods
fun loadTweetUrl(
url: String,
hideMedia: Boolean? = null,
hideThread: Boolean? = null,
theme: TweetTheme? = null,
doNotTrack: Boolean? = null,
)
fun loadTweetId(
id: String,
hideMedia: Boolean? = null,
hideThread: Boolean? = null,
theme: TweetTheme? = null,
doNotTrack: Boolean? = null,
)
Only id or url is required. The other arguments are optional which I think are self explanatory but if you want you can read about them here